2021年3月24日星期三

How to set Cookie in react fetch

Here is my curl code which one i am trying over swagger is working.

    curl -X 'GET' \      'http://178.154.200.180:8080/api/v1/user/brands' \      -H 'accept: application/json' \      -H 'Cookie: wba-session-id=13afbb83-a4e1-4fd5-b8bb-b35187164188'  

The same curl code i converted to react fatch but it is saying un authorized.

        useEffect(() => {              let headers = {                  'accept': 'application/json',                  'Cookie': '13afbb83-a4e1-4fd5-b8bb-b35187164188'              }              fetch('http://178.154.200.180:8080/api/v1/user/brands', { headers: headers })                .then(res => res.json())                .then(res => {                   alert(res)               })          }, [])  

Please take a look where i am doing wrong.

https://stackoverflow.com/questions/66792915/how-to-set-cookie-in-react-fetch March 25, 2021 at 12:04PM

没有评论:

发表评论