0

I'm front-end dev and my app run inside android WebView, after I call api method form my react app by axios(or fetch/xhr), WebView developers inject some important headers into my request.

they expect me to reed request headers and show some where inside my react app.
the problem is how can I read request header after api call???

I installed mode-header extension to simulate development environment. in chrome devtool I can see other request headers injected by browser into my api requests but I cant read them!

Mohamad Ahmadi
  • 248
  • 2
  • 7
  • 1
    Check this out https://axios-http.com/docs/res_schema does this help? – JorensM Jan 15 '23 at 07:56
  • thanks, no it doesn't! I couldn't find request headers inside response schema, please help! – Mohamad Ahmadi Jan 15 '23 at 08:04
  • On the page I linked, it says you can access header from `response.headers` – JorensM Jan 15 '23 at 08:20
  • but inside `response.headers` only show response headers. I need `request headers` ! – Mohamad Ahmadi Jan 15 '23 at 08:34
  • Sorry I misread your question, I thought you needed response headers. https://axios-http.com/docs/interceptors could this help perhaps? This shows how to intercept request before it is sent – JorensM Jan 15 '23 at 08:57
  • After rereading your question once more, from what I understand your app runs inside a WebView in another app. I don't think it is possible to view the request after it has been passed to the external app. – JorensM Jan 15 '23 at 09:04
  • Check out this SO post, it might be useful: https://stackoverflow.com/questions/19692617/how-do-i-see-request-headers-on-android-webview-requests – JorensM Jan 15 '23 at 09:13
  • did you even read the question? I want to read request headers in react after api call. i don't need it in WebView. interceptor is about `set request headers` and `read response headers` not `read request headers` ! also i don't access WebView ! – Mohamad Ahmadi Jan 15 '23 at 09:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/251150/discussion-between-mohamad-ahmadi-and-jorensm). – Mohamad Ahmadi Jan 15 '23 at 09:59

0 Answers0