Hey folks, I’m new to Apollo Client 3.5.10 and I’m having difficulties with client https://api.graphql.jobs/
Getting when running inside Reactjs
Uncaught (in promise) Error: Unexpected token < in JSON at position 0
at new ApolloError (index.ts:58:1)
at Object.error (QueryManager.ts:310:1)
at notifySubscription (module.js:137:1)
at onNotify (module.js:176:1)
at SubscriptionObserver.error (module.js:229:1)
at Object.error (asyncMap.ts:48:1)
at notifySubscription (module.js:137:1)
at onNotify (module.js:176:1)
at SubscriptionObserver.error (module.js:229:1)
at iteration.ts:13:1
Here is My Mutation
import {gql} from '@apollo/client';
export const CREATE_JOB_MUTATION = gql`
mutation postJob(
$title: String!,
$commitmentId: ID!,
$companyName: String!,
$locationNames: String!,
$userEmail: String!,
$description: String!,
$applyUrl: String!
){
postJob(
title: $title,
commitmentId: $commitmentId,
companyName: $companyName,
locationNames: $locationNames,
userEmail: $userEmail,
description: $description,
applyUrl: $applyUrl
){
id
}
}
`;
Query Variable
mutation{
postJob(input:{
title: "Title Goes here...",
commitmentId: "id...",
companyName: "companyName.....",
locationNames: "locationNames....",
userEmail: "test@test.com",
description: "description",
applyUrl: "test.com"
}){
id
}
}
URL:
https://api.graphql.jobs/
Works fine when I run this on POSTMAN but getting error when try to run inside react
Query on Reactjs Side
const postNewJob = async () => {
console.log("Posting New Job");
await postJob({
variables: {
input:{
title,
commitmentId: id,
companyName: name,
locationNames: location,
userEmail: email,
description,
applyUrl: 'https://www.google.com'
}
}
});
In the Dev-Tool I get this in the network tab
operationName: "postJob", variables: {},…}
operationName: "postJob"
query: "mutation postJob($title: String!, $commitmentId: ID!, $companyName: String!, $locationNames: String!, $userEmail: String!, $description: String!, $applyUrl: String!) {\n postJob(\n title: $title\n commitmentId: $commitmentId\n companyName: $companyName\n locationNames: $locationNames\n userEmail: $userEmail\n description: $description\n applyUrl: $applyUrl\n ) {\n id\n __typename\n }\n}"
variables: {}
Thanks In Advance