is there any way to add X-CSRF-TOKEN header globally.
Without add it to every request.
sure... just create a new function
const headers = ()=> ({headers: {'X-CSRF-TOKEN': 'whatever'}});
const request = (...args)=>
args.length > 1 || typeof args[0] === 'string'
? m.request(args[0], Object.assign(headers(), args[1] || {}))
: m.request(Object.assign(headers(), args[0] || {}));
Then just use that in stead of m.request
Alternatively you can monkeypatch m.request with something like the above function.
Or write a util like this: https://gist.github.com/orbitbot/9e950029e9e8eba0bc8cd7710445df63
@nordfjord Thank you :+1:
@isiahmeadows need your help here. is there any way to add a global config on all mithril requests
@naveennagan No, and in general, I would be against it. It's pretty easy to create a wrapper function setting exactly what you need.
Most helpful comment
sure... just create a new function
Then just use that in stead of m.request
Alternatively you can monkeypatch m.request with something like the above function.