I have created a Postman mock server. I am calling the server in my web application using axios
as below:
const response = await axios.get(`${BASE_URL}/products`, {
'headers': {
'Content-Type': 'application/json'
}
});
const axiosData = response.data;
return axiosData.data;
Weirdly axiosData
is a string! Therefore axiosData.data
which contains the actual data from the response is undefined
.
How can I get my Postman mock server to return axiosData
as JSON
?
Note: I have also set a response header: Content-type: application/json
for my response in Postman.
Edit:
This is the response I get back from the mock server (which is string
):