import { setContext } from '@apollo/client/link/context';
const setheader = setContext((request, previousContext) => {
let head: any = {};
head.categoryName = localStorage.getItem('categoryName');
return head;
});
const link = new HttpLink({
headers: {categoryName : localStorage.getItem('categoryName')}
});
export const client = new ApolloClient({
uri: 'url Hidden',
cache: new InMemoryCache(),
link,
}) as any;
apllo gql
I am adding context and link to add that while exporting the client
the error says
"Error: Failed to execute 'fetch' on 'Window': Invalid value"
and it's not valid JSON.
as per documentation it looks correct please have look and help me