uidotdev / react-query-api Goto Github PK
View Code? Open in Web Editor NEWThe API which we use for the React Query course. Built with Mock Service Worker
License: MIT License
The API which we use for the React Query course. Built with Mock Service Worker
License: MIT License
Edit: Found the error. I was passing the issue id
to the request instead of the issue number
.
MSW Worker always responds with 404
regardless of the searched issue with the body {"message":"Not found"}
. My query code is below.
import { IssueStatus } from "@enums"
import { useQuery } from "react-query"
const toDomainIssue = (dto: IssueDto): Issue => ({ labelIDs: dto.labels, ...dto })
export function useIssue(number: string) {
const keys = ["issues", number]
function fetcher({ queryKey }: { queryKey: typeof keys }): Promise<Issue> {
const [, number] = queryKey
return fetch(`/api/issues/${number}`)
.then((res) => res.json())
.then((dto) => toDomainIssue(dto))
}
return useQuery(keys, fetcher)
}
Compared with the screenshot below taken from the video course, the endpoint to where I am requesting does not appear incorrect. Impossible to progress on the course unless this is fixed.
"@uidotdev/react-query-api": "^0.1.18"
npm ERR! code 1
npm ERR! path /home/sinnerd/Videos/React/vitetest/client/node_modules/ts-eager/node_modules/esbuild
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sinnerd/.npm/_logs/2023-03-01T11_12_46_703Z-debug-0.log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.