javascript - Amadeus City and Airports Location API 自动完成系统
问题描述
我正在将自动完成系统添加到我正在开发的预订网站。我了解自动完成系统从预先填充的数据中获取。所以我正在尝试从 https://test.api.amadeus.com/v1/reference-data/locations获取位置/机场代码以查看所有位置的列表这样我就可以设计自动完成系统,但我得到了不好的响应,我的应用程序缺少一个重要参数。我正在尝试显示位置列表。我希望有人能指出我哪里出错了。
"use_strict";
function getLocations(){
let url = "https://test.api.amadeus.com/v1/reference-data/locations";
fetch(url,{
method:"GET",
headers:{
"Content-Type":"application/json",
"Authorization":"Bearer BgRWNa48WGmqPowlRCMvIwHt6a96"
},
mode:"cors",
catch:"default"
}).then(function(response){
return response.json();
}).then(function(data){
console.log(data);
}).catch(function(error){
console.log(error);
});
}
getLocations();
**
:对象{状态:400,代码:32171,标题:“强制性数据丢失”,...}
** </p>
解决方案
您缺少必需的查询参数。根据API 参考,需要subType
(AIRPORT 或 CITY)和keyword
参数。例如:
https://test.api.amadeus.com/v1/reference-data/locations?subType=AIRPORT&keyword=LON
将返回名称中包含关键字的机场列表LON
(伦敦希思罗机场、伦敦盖特威克机场、伦敦斯坦斯特德机场等)
推荐阅读
- php - UnexpectedValueException 用户必须实现 CanResetPassword 接口
- asp.net-mvc - 子域内的 ASP.NET MVC 应用程序中的表单数据始终为空
- flutter - '这个表达式的类型是'void',所以它的值不能被使用。' Flutter 中的 setState() 错误
- github - 如何为 github 问题安装用户反馈投票?
- swift - Segue不断重新加载屏幕
- python - 烧瓶路由可以同时返回 IO 流和变量吗?
- native-web-component - 如何阻止原生 Web 组件发生 FOUC
- java - 从 URL 中提取查询值
- android - com.aldebaran.qi 的 UnsatisfiedLinkError
- c# - 无法解释的 CS0102:在属性设置器上