Last active
March 31, 2022 14:12
-
-
Save scottgamer/7da120cca3809092f8a0cbfde04c5343 to your computer and use it in GitHub Desktop.
msw initial handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { rest } from "msw"; | |
| import CONSTANTS from "../constants"; | |
| function getPosts() { | |
| return rest.get(`${CONSTANTS.API_URL}/posts`, (req, res, ctx) => { | |
| return res( | |
| ctx.status(200), | |
| ctx.json([ | |
| { | |
| userId: 1, | |
| id: 1, | |
| title: "Post 1 title", | |
| body: "Post 1 body", | |
| }, | |
| { | |
| userId: 1, | |
| id: 2, | |
| title: "Post 2 title", | |
| body: "Post 2 body", | |
| }, | |
| ]) | |
| ); | |
| }); | |
| } | |
| export const handlers = [getPosts()]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment