-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a40a52
commit 3d959be
Showing
7 changed files
with
1,039 additions
and
1,118 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { setupWorker } from "msw"; | ||
import { setupWorker } from "msw/browser"; | ||
import { handlers } from "./handlers"; | ||
|
||
export const worker = setupWorker(...handlers); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
import { rest } from "msw"; | ||
import { http, graphql, HttpResponse } from "msw"; | ||
import { Book, Review } from "./types"; | ||
|
||
console.log("handlers"); | ||
|
||
export const handlers = [ | ||
rest.get("https://my.backend/book", (_req, res, ctx) => { | ||
return res( | ||
ctx.json<Book>({ | ||
title: "Lord of the Rings", | ||
imageUrl: "/book-cover.jpg", | ||
description: | ||
"The Lord of the Rings is an epic high-fantasy novel written by English author and scholar J. R. R. Tolkien.", | ||
}), | ||
); | ||
http.get("https://my.backend/book", () => { | ||
return HttpResponse.json<Book>({ | ||
title: "Lord of the Rings", | ||
imageUrl: "/book-cover.jpg", | ||
description: | ||
"The Lord of the Rings is an epic high-fantasy novel written by English author and scholar J. R. R. Tolkien.", | ||
}); | ||
}), | ||
rest.get("/reviews", (_req, res, ctx) => { | ||
return res( | ||
ctx.json<Review[]>([ | ||
{ | ||
id: "60333292-7ca1-4361-bf38-b6b43b90cb16", | ||
author: "John Maverick", | ||
text: "Lord of The Rings, is with no absolute hesitation, my most favored and adored book by‑far. The trilogy is wonderful‑ and I really consider this a legendary fantasy series. It will always keep you at the edge of your seat‑ and the characters you will grow and fall in love with!", | ||
}, | ||
]), | ||
); | ||
http.get("/reviews", () => { | ||
return HttpResponse.json<Review[]>([ | ||
{ | ||
id: "60333292-7ca1-4361-bf38-b6b43b90cb16", | ||
author: "John Maverick", | ||
text: "Lord of The Rings, is with no absolute hesitation, my most favored and adored book by‑far. The trilogy is wonderful‑ and I really consider this a legendary fantasy series. It will always keep you at the edge of your seat‑ and the characters you will grow and fall in love with!", | ||
}, | ||
]); | ||
}), | ||
]; |
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
Oops, something went wrong.