I am running an Api inside componentDidUpdate. My code is -
componentDidUpdate(prevProps, nextProps) {
const getSalaries = async () => {
console.log("this ran");
const data = await api.get(
`/client/${this.props.client.id}/salary`
);
};
if (this.props.client !== prevProps.client) {
this.props.client.id !== undefined && getSalaries();
}
}
The statusCode returned by this request is 200 but there is no data returned. There is nothing wrong with this api. I have checked this on postman. When I console.log(data), it returned following-
{ "data": "", "status": 200, "statusText": "", "headers": { "access-control-expose-headers": "Access-Control-Expose-Headers, Content-Disposition", "cache-control": "no-cache, no-store, max-age=0, must-revalidate", "expires": "0", "pragma": "no-cache" }, "config": { "transformRequest": {}, "transformResponse": {}, "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "headers": { "Accept": "application/json, text/plain, /", "Authorization": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJVcGVuZHJhRGhhbWFsYUBrb2l6YWkuY29tIiwibmJmIjoxNjQ5OTg2MDcxLCJVc2VyLlVVSUQiOiI2MjIxZDdlZmM5ZTc3YzAwMDEwOWU1MWMiLCJpc3MiOiJ3d3cua29pemFpLmNvbSIsImV4cCI6MTY1MDAxNDg3M" }, "method": "get", "url": "http://34.124.147.12:8181/api/v1/client/6225c701c9e77c00014c6796/salary" }, "request": {} }