Upload file using Apollo and React


#1

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(),
});


#2

i got this error on my console.

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


#3

This article by Prosper Otemuyiwa should help you.


#4

i am using

in a react native app and with a meteor backend using

works fine!