I’m working on integrating the Skyscanner Flights Scraper API using Express.js and Axios. The goal is to fetch flight data using the /flights/search-everywhere endpoint. Here’s what I’ve done so far:
Successfully obtained the fromEntityId from the /flights/auto-complete endpoint.
Attempted to use this fromEntityId to search flights via /flights/search-everywhere.
When I test this in the RapidAPI Playground, it works perfectly and returns valid flight data. However, when I run the same query through my local server and Postman, it always returns:
{
“message”: “No flights found”
}
Observations:
In RapidAPI: The request returns valid flight data.
In Postman: The request always responds with “message”: “No flights found”.
I suspect there’s an issue with how I’m passing the fromEntityId or how Axios handles the request, but I’m not sure what I’m doing wrong.
Things I’ve Tried:
Verified that the API key and host are correct.
Double-checked the request headers and parameters against the RapidAPI playground.
Logged the fromEntityId to ensure it’s being received correctly in the server.
/* server.js */
app.post('/flights', async (req, res) => {
const { fromEntityId } = req.body;
try {
const response = await axios.get(`https://${API_HOST}/flights/search-everywhere`, {
headers: {
'X-RapidAPI-Host': API_HOST,
'X-RapidAPI-Key': API_KEY,
},
params: {
query: fromEntityId,
},
});
const flights = response.data?.data?.results || null;
if (!flights) {
return res.json({ message: 'No flights found' });
}
res.json(flights);
} catch (error) {
console.error('Error fetching flights:', error);
res.status(500).json({ message: 'Error fetching flights. Please try again.' });
}
});
// Start the server
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});
PostMan Doesn’t WorkAPI Website Works
Could you please kindly help? Thank you!
Observations:
In RapidAPI: The request returns valid flight data.
In Postman: The request always responds with “message”: “No flights found”.
I suspect there’s an issue with how I’m passing the fromEntityId or how Axios handles the request, but I’m not sure what I’m doing wrong.
Things I’ve Tried:
Verified that the API key and host are correct.
Double-checked the request headers and parameters against the RapidAPI playground.
Logged the fromEntityId to ensure it’s being received correctly in the server.