javascript - Can't get headers from Http POST request with Axios - Stack Overflow

I have this POST request with axios in React :postRunSimulation(simulationId) {var requestAnalysis = `$

I have this POST request with axios in React :

postRunSimulation(simulationId) {
  var requestAnalysis = `${configFile.web.backend}analysis/${simulationId}/run`;
  return axios.post(requestAnalysis)
  .then(function (response) {
    return response.headers;
  }, function(error) {
    throw new Error('An error occurred : ' + error.status + ' - ' + error.statusText);
  });
},

The object I get in return has a headers property but it's empty. If I make the same call with Postman, I get the headers. What am I doing wrong ?

I have this POST request with axios in React :

postRunSimulation(simulationId) {
  var requestAnalysis = `${configFile.web.backend}analysis/${simulationId}/run`;
  return axios.post(requestAnalysis)
  .then(function (response) {
    return response.headers;
  }, function(error) {
    throw new Error('An error occurred : ' + error.status + ' - ' + error.statusText);
  });
},

The object I get in return has a headers property but it's empty. If I make the same call with Postman, I get the headers. What am I doing wrong ?

Share Improve this question asked Jul 21, 2016 at 17:35 ClafoutiClafouti 4,6655 gold badges32 silver badges39 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

If your back-end is running on a different host or port than the web app, the browser can only access the following 6 response headers by default: Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, and Pragma (see also this answer). If the server does not return any of them, the headers will be empty.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745373494a4624899.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信