尝试在Skyscanner API上使用POST调用

此刻我要做的只是记录我试图通过POST调用从Sky Scanner API检索的数据,但出现500错误。关于我在做什么的任何想法在这里?

Btw新程序员

更新:错误400

const KEY = '123';

fetch("https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/pricing/v1.0",{
	"method": "POST","headers": {
		"x-rapidapi-host": "skyscanner-skyscanner-flight-search-v1.p.rapidapi.com","x-rapidapi-key": `${KEY}`,"content-type": "application/x-www-form-urlencoded"
	},body: new URLSearchParams({
		"inboundDate": "2019-11-10","cabinClass": "business","children": "0","infants": "0","country": "US","currency": "USD","locale": "en-US","originPlace": "SFO-sky","destinationPlace": "LHR-sky","outboundDate": "2019-11-20","adults": "1"
	  })
})
.then(response => {
	console.log(response);
})
.catch(err => {
	console.log(err);
});

h5531856138 回答:尝试在Skyscanner API上使用POST调用

确保输入正确的“ x-rapidapi-key”:${KEY}

因为它显示401未经授权的错误

{
 "url": "https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/pricing/v1.0","redirected": false,"status": 401,"ok": false,"statusText": "Unauthorized",}
本文链接:https://www.f2er.com/3148160.html

大家都在问