This is more a javascript question than a Sentinel Hub question but I hope that some people here know the answer.
I saw the announcement of the new statistical API and its documentation at:
However I could not wrap my head around that axios/oauth business. I am able to use axios to get an access token to use the Catalog API, but I do not know how to use this access token as the “oauth” object shown in the previous link to make POST requests against the new statistical API URL.
Has anyone managed to make work the whole pipeline?
PS: the axios documentation was of no help either.
Where data is the JSON object that you are sending to the API (I suggest using Statistical mode on Requests Builder, under Request Preview to get that object in a more friendly way).
To make auth work, basically you need to attach the HTTP header Authorization: Bearer <token> to your request.
Let me know if I can assist you further.
Ignasi Espinosa
Edit: Note that you may also need to add ‘Content-type’: ‘application/json’ and ‘Accept’: ‘application/json’ headers in the headers object passed to axios.
@ignasi.espinosa but this approach has a problem with token , every time the token expires you have to change it in code which not a good pratcice , is there any other alternative