axios获取,放置,发布方法请求失败,状态码为403

时间:2019-11-11 08:28:16

标签: node.js express axios

Error: Request failed with status code 403
    at createError (C:\Yatin\API\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\Yatin\API\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\Yatin\API\node_modules\axios\lib\adapters\http.js:237:11)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

当我在函数中执行以下代码时,它显示上述错误。直到一段时间后,它的运行状况还算不错,但是突然之间,它现在不起作用了。

var azureREST_listContainerURI = <URL_that is generated here by calling other functions>
axios({
            method: 'get',
            url: azureREST_listContainerURI
          })
           .then(function (response) {

            parser.parseString(response.data, function (err, result) {
                if(err) throw err
              for(let containerObj of result.EnumerationResults.Containers[0].Container)
              {
                  var containerobject = {
                      "Name":containerObj['Name'][0],
                      "properties":{
                          "last_modified":containerObj['Properties'][0]['Last-Modified'][0]
                          }
                      }
                      customJSONResponse['containers'].push(containerobject);
              }
              res.send(customJSONResponse) 
           })
          })
           .catch(function (error) {
           res.send({error:error})
           console.log(error.stack)
            console.log("Error while calling Azure REST endpoint : " + error);
           });

这不起作用并显示上述错误,尽管当我尝试通过硬编码单引号内的axios.get中的url参数来执行相同的代码时,它绝对可以正常工作。

0 个答案:

没有答案