I am adding the AutoComplete System to a booking website that I am developing. I understand that the autoComplete system fetches from a pre-populated data.So I am trying to locations/airport codes from https://test.api.amadeus.com/v1/reference-data/locations to view the list of all locations so that I can design the auto-complete system but I get a bad response, my application is missing an important parameter.I am trying to display a list of locations. I hope someone can point out where I have gone wrong.
"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();
**
: Object { status: 400, code: 32171, title: "MANDATORY DATA MISSING", … }
**
You are missing the mandatory query parameters. According to the API reference, subType
(AIRPORT or CITY) and keyword
parameters are needed. For example:
https://test.api.amadeus.com/v1/reference-data/locations?subType=AIRPORT&keyword=LON
will return a list of airports whose name contains the keyword LON
(London Heathrow, London Gatwick, London Stansted, etc.)