Skip to content

Instantly share code, notes, and snippets.

@marta-pinkowska
Last active February 20, 2023 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marta-pinkowska/2441ce919c1053770e0d4cad48cc779a to your computer and use it in GitHub Desktop.
Save marta-pinkowska/2441ce919c1053770e0d4cad48cc779a to your computer and use it in GitHub Desktop.
// 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