Last active
February 20, 2023 17:10
-
-
Save marta-pinkowska/2441ce919c1053770e0d4cad48cc779a to your computer and use it in GitHub Desktop.
This file contains 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
// src/mocks/handlers.js | |
import { rest } from "msw"; | |
export const handlers = [ | |
// Handles a POST request | |
rest.post("https://fancy-app.com/postToThisEndpoint", (req, res, ctx) => { | |
return res( | |
// Respond with a 200 status code | |
ctx.status(200) | |
); | |
}), | |
// Handles a GET request | |
rest.get("https://fancy-app.com/getSomeData", (req, res, ctx) => { | |
return res( | |
ctx.status(200), | |
ctx.json({ | |
data: "fancy data string", | |
}) | |
); | |
}), | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment