使用POST方法获取API,给我500(内部服务器错误)

问题描述 投票:0回答:1

我正在使用带有POST方法的访存来从index.html页面中的API获取数据,但是正在获取500个状态代码,请有人指导我代码中可能存在的错误

<body>
<h1>Flights Finder</h1>

<script type="text/javascript">
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': 'API_KEY',
      'content-type': 'application/x-www-form-urlencoded'
    },
    'body': {
      'inboundDate': '2019-11-24',
      'cabinClass': 'business',
      'children': '0',
      'infants': '0',
      'country': 'US',
      'currency': 'USD',
      'locale': 'en-US',
      'originPlace': 'SFO-sky',
      'destinationPlace': 'LHR-sky',
      'outboundDate': '2019-11-16',
      'adults': '1'
    }
})
.then(response => {
    console.log(response);
})

.catch(err => {
    console.log(err);
});
</script>
</body>
post fetch fetch-api internal-server-error http-status-code-500
1个回答
0
投票

错误代码500是内部服务器错误。您应该检查服务器上是否没有错误。

© www.soinside.com 2019 - 2024. All rights reserved.