Fetch Failed for db Client
steven-tey opened this issue · 1 comments
steven-tey commented
Great work on this team!!
Following the example here gives me "Fetch failed" error when I'm trying to do it in Next.js API routes:
error - Error [TypeError]: fetch failed
at Object.processResponse (evalmachine.<anonymous>:3033:34)
at <unknown> (evalmachine.<anonymous>:3366:42)
at <unknown> (node:internal/process/task_queues:141:7)
at AsyncResource.runInAsyncScope (node:async_hooks:199:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
However when I switched to the example in the blog post with import { connect } from "@planetscale/database";
it worked.
dgraham commented
When you print the value of your DATABASE_URL
environment variable, does it look like the following format? If the environment variable hasn't been set for the process, it's likely that it's trying to fetch a null
URL and failing.
console.log(process.env['DATABASE_URL'])
// => mysql://<user>:<password>@<host>