Coder Social home page Coder Social logo

react-query-api's People

Contributors

alexanderson1993 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

resherra

react-query-api's Issues

Unable to fetch from `/api/issues/:number`

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.

image
image
image

Can't install this package using npm or bun anything

"@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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.