Upload file using Apollo and React

Hello anyone here already uses apollo-upload-client?
i am having a hard time figuring out how to implement it into my app.

const authLink = setContext((_, { headers }) => {
const token = localStorage.getItem(‘token’);
return {
headers: {
…headers,
authorization: token ? Bearer ${token} : “”,
}
}
});

const link = new createUploadLink({ uri: ‘/graphiql’ })
const client = new ApolloClient({
link: authLink.concat(link),
cache: new InMemoryCache(),
});

i got this error on my console.

[Network error]: SyntaxError: Unexpected token < in JSON at position 0

This article by Prosper Otemuyiwa should help you.

2 Likes

i am using

in a react native app and with a meteor backend using

works fine!

1 Like