Not able to fetch cart details of guest users in Magento using custom API by sending SID (session id) in axios request from Reactjs frontend

Viewed 23

We have created custom APIs in Magento to handle the frontend. We are using Reactjs for the frontend and Axios to hit the APIs.

All the APIs are working fine if we hit from POSTMAN or from the flutter app. We are getting the SID(session-id) from APIs response as same as the SID sent in a request from the previous response.

But in the case of Reactjs and Axios, in each APIs response, the SID(session-id) is different. So, in the case of guest users, we are able to add the products to the cart but are not able to fetch the cart details as SID gets updated.

request:

{
    "headers": {
        "cache-control": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
        "content-length": "192",
        "content-type": "text/html; charset=UTF-8",
        "expires": "Thu, 19 Nov 1981 08:52:00 GMT",
        "pragma": "no-cache"
    },
    "config": {
        "transitional": {
            "silentJSONParsing": true,
            "forcedJSONParsing": true,
            "clarifyTimeoutError": false
        },
        "transformRequest": [
            null
        ],
        "transformResponse": [
            null
        ],
        "timeout": 330000,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": 50000,
        "maxBodyLength": -1,
        "headers": {
            "Accept": "*/*"
        },
        "withCredentials": false,
        "url": "******************************************",
        "method": "post",
        "baseURL": "",
        "params": {
            "version": "1.8",
            "SID": "bbcosjdf6s4lrd3",
            "__store": "default"
        },
        "responseType": "json",
        "maxRedirects": 5,
        "data": {},
        "meta": {
            "requestStartedAt": 1641359394946
        }
    },
    "request": {}
}
0 Answers
Related