Using the client middleware, how do I set a header. I'm talking about when you do a request in this way:
return {
types: [LOGOUT, LOGOUT_SUCCESS, LOGOUT_FAIL],
promise: (client) => client.get('/logout')
};
Thanks.
You'd have to modify ApiClient.js in order to accept headers but I did it in the following way:
return {
types: [LOGOUT, LOGOUT_SUCCESS, LOGOUT_FAIL],
promise: (client) => client.get('/logout', { headers: { [header-name]: [header-value], ... })
};
ApiClient.js
class ApiClient {
constructor(req) {
methods.forEach((method) => {
this[method] = (path, { params, data, attach, field, headers, local, external = false } = {}) => new Promise((resolve, reject) => {
const request = superagent[method](external ? path : formatUrl(path, local));
const cookie = req.get("cookie");
if (headers) {
request.set(headers);
}
...
Most helpful comment
You'd have to modify
ApiClient.jsin order to accept headers but I did it in the following way:ApiClient.js