Our blazing fast Grid component built with pure JavaScript


Post by germandsantana »

Hi,

I am looking for a way to modify the headers of the request in the ajaxstore before its sent to the server. An interceptor or similar that allows to modify request properties. Something like axios interceptors.

We are using a security framework, auth0 spa sdk to get authorization tokens. And this framework works requesting tokens and dealing with the refresh process by itself , but this process is by demand, they provide an async function to get an auth token , so to use it We have to call it and await before the request is sent to the server.

We don't want to implement a timer to keep the token refreshed on all instances of the ajaxstores.
We tried the beforeRequest listener registering an async function but it doesn't work with the await declaration , the request is sent before the modification of the headers of the ajaxstore instance.

Do you know How We could modify the request before is sent?
Thanks


Post by alex.l »

Hi germandsantana ,

Yes, beforeRequest cannot be used with async listener. But, as a possible solution, you could get tokens you need before store load call and apply headers using https://www.bryntum.com/docs/grid/#Core/data/AjaxStore#config-headers or even more with https://www.bryntum.com/docs/grid/#Core/data/AjaxStore#config-fetchOptions property.

All best,
Alex

All the best,
Alex


Post Reply