ByteGrad / Professional-React-and-Next.js-Course

This repo contains everything you need as a student of the Professional React & Next.js Course by ByteGrad.com
https://bytegrad.com/courses/professional-react-nextjs
111 stars 58 forks source link

NextJS - fetch request throwing TypeError: fetch failed #10

Open AllThingsSmitty opened 3 months ago

AllThingsSmitty commented 3 months ago

I'm on video #213 and when I attempt to perform the fetch of https://bytegrad.com/course-assets/projects/evento/api/events?city=austin I get the following error:

Internal error: TypeError: fetch failed

I'm running Node 21.6.2 for the project so I'm not sure what the issue might be. The full error output is below. Do you have any thoughts so I can continue with the video and project? I've included the package.json items further below.

 ⨯ Internal error: TypeError: fetch failed
    at node:internal/deps/undici/undici:12443:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Cause: Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
    at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}
 ⨯ Internal error: TypeError: fetch failed
    at node:internal/deps/undici/undici:12443:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
digest: "3079390902"

package.json:

{
  "name": "evento",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "clsx": "^2.1.1",
    "framer-motion": "^10.16.4",
    "next": "14.0.1",
    "react": "^18",
    "react-dom": "^18"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0.1",
    "eslint": "^8",
    "eslint-config-next": "14.0.1",
    "postcss": "^8",
    "tailwindcss": "^3.3.0",
    "typescript": "^5"
  }
}
ByteGrad commented 3 months ago

Hi Matt,

It’s hard to say. Could be an Internet connection problem, maybe dev server isn’t running, etc.

Wesley

On Fri, 26 Apr 2024 at 21:50, Matt Smith @.***> wrote:

I'm on video #213 and when I attempt to perform the fetch of https://bytegrad.com/course-assets/projects/evento/api/events?city=austin I get the following error:

Internal error: TypeError: fetch failed

I'm running Node 21.6.2 for the project so I'm not sure what the issue might be. The full error output is below. Do you have any thoughts so I can continue with the video and project? I've included the package.json items further below.

⨯ Internal error: TypeError: fetch failed at node:internal/deps/undici/undici:12443:11 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Cause: Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) { errno: -4077, code: 'ECONNRESET', syscall: 'read' } ⨯ Internal error: TypeError: fetch failed at node:internal/deps/undici/undici:12443:11 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) digest: "3079390902"

package.json:

{ "name": "evento", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "clsx": "^2.1.1", "framer-motion": "^10.16.4", "next": "14.0.1", "react": "^18", "react-dom": "^18" }, "devDependencies": { @./node": "^20", @./react": "^18", @.***/react-dom": "^18", "autoprefixer": "^10.0.1", "eslint": "^8", "eslint-config-next": "14.0.1", "postcss": "^8", "tailwindcss": "^3.3.0", "typescript": "^5" } }

— Reply to this email directly, view it on GitHub https://github.com/ByteGrad/Professional-React-and-Next.js-Course/issues/10, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATSBVCKAQWLWXJMQE5RSIJTY7KVXXAVCNFSM6AAAAABG3KU5RKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3DMNBRGQ2TEMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

AllThingsSmitty commented 2 months ago

I was able to get past that issue by adding a .env.local file to the project with the following value:

NODE_TLS_REJECT_UNAUTHORIZED = "0"

Not sure how much further that will get me but it works for now.

AllThingsSmitty commented 2 months ago

Looks like that only got me a few videos further before the issue came up again with future fetch requests.