How to get Header Location value from a Fetch request in browser

后端 未结 2 727
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-04 21:29

From a ReactJS - Redux front app, I try to get the Location Header value of an REST API response.

When I Curl this :

curl -i -X POST -H \"Authorizat         


        
相关标签:
2条回答
  • 2021-01-04 21:34

    Besides to expose the Location Header in the server.

    I just could access the location in the react application with:

    response.headers.location;
    
    0 讨论(0)
  • 2021-01-04 22:00

    Thanks to John, I've found the answer.

    I just had to put

    Access-Control-Expose-Headers: Location
    

    To my response headers and it worked, so now I can access Location value with :

    response.headers.get('Location');
    

    Thx John !

    0 讨论(0)
提交回复
热议问题