'How to pass multiple headers in Apollo GraphQI?
I wanted to know how to pass multiple headers in Apollo GraphQl as i know how to pass single but not multiple headers.Any solutions or suggestions appreciated.Thanks in advance!
For suppose the below code is for single header how i can pass multiple headers in that way?
const authLink = setContext((_, { headers }) => {
// get the authentication token from local storage if it exists
const token = localStorage.getItem('token');
// return the headers to the context so httpLink can read them
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
}
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|