错误:未被捕获(承诺):对象:{“状态”:401,“ URL”}

时间:2019-07-08 15:17:38

标签: json angular url ionic4

我有使用angular的Ionic应用程序。我想使用自己的用户名和api键从flightaware获取数据json api。为了获取数据,我使用了native http plugin。我遵循了Flightaware的步骤documentation来获取数据json。我还根据测试代码在该文档中做了同样的jquery示例。

  testing(){

  let fxml_url = 'http://myusername:myApiKey@flightxml.flightaware.com/json/FlightXML2/';


this.http.get(fxml_url, {
}, {}).then(data=>{


console.log('checking :' +data.data + "Status : " + data.status)
})


  }

但是当我运行我的应用程序时,控制台出现错误

ERROR Error: Uncaught (in promise): Object: {"status":401,"url":"https://flightxml.flightaware.com/json/FlightXML2/MetarEx?airport=KAUS&howMany=1","error":"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n\n<html>\n<head>\n<title>Authentication Required</title>\n</head>\n<body>\n<h1>Authentication Required</h1>\n\n\n</body>\n</html>\n"}
    at resolvePromise (polyfills.js:3189)
    at resolvePromise (polyfills.js:3146)
    at polyfills.js:3250
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2781)
    at Object.onInvokeTask (vendor.js:53413)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2780)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (polyfills.js:2553)
    at drainMicroTaskQueue (polyfills.js:2959) 

he return full url with username and api key

他返回带有用户名和api键的完整网址

0 个答案:

没有答案