Unexpected token P in JSON at position 0 #7152
-
I get an error when using GraphQL Codegen:
In Network Tab, it shows:
This is when I use it like: const { isLoading, isError, data, error } = useGetCurrentUserQuery()
if (isLoading) return <Loading />
if (isError) return <Error error={error} /> It loads the My schema: ./src/server/graphql/schema.graphql
documents:
- '**/*.graphql'
- '!/src/server/graphql/schema.graphql'
generates:
src/client/graphql/types.generated.ts:
plugins:
- typescript
./:
preset: near-operation-file
presetConfig:
baseTypesPath: src/client/graphql/types.generated.ts
plugins:
- add:
content: &comment "/* DO NOT EDIT! this file was generated by graphql-codegen */\n/* eslint-disable */"
- typescript-operations
- typescript-react-query
config:
fetcher:
endpoint: '`${process.env.NEXT_PUBLIC_BASE_URL}/api`' I want to use And how do I fix this? I even tried putting the following under fetchParams:
headers:
credentials: include
content-type: 'application/json' |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think I put config:
fetcher:
endpoint: '`${process.env.NEXT_PUBLIC_BASE_URL}/api`'
fetchParams:
headers:
credentials: include
content-type: application/json Although, would love to know how to use |
Beta Was this translation helpful? Give feedback.
I think I put
credentials: include
& it started working:Although, would love to know how to use
ky
but I don't think I need it in auto-generated code. It does come with quite some goodies over fetch.