Apollo upload ... request not a valid JSON

Viewed 13

ERROR index.js:29 Uncaught (in promise) Error: Unexpected token 'T', "This opera"... is not valid JSON

client setup

const authLink = setContext(async (_, { headers }) => {
  const token = await getToken() 
  return {
    headers: {
      ...headers,
      authorization: token,
    }
  }
});

export const client = new ApolloClient({
  link: from([errorLink, authLink, uploadLink,]),
  cache: new InMemoryCache()
});

server setup

import graphqlUploadExpress from "graphql-upload/graphqlUploadExpress.mjs"
app.use(graphqlUploadExpress()); 
  server.applyMiddleware({
    app,
    path: '/',
  });

Mutation Sending request

                try {
                    i = await convertBase64ToBlob(img)
                    console.log("Created blob", i)
                } catch (e) {
                    console.log("Unable to create blog")
                }
                updateUser({ variables: { img: i } })
0 Answers
Related