I am trying to fetch and visualize a list of data with a GET request while passing two parameters. However, I am encountering an error 400 when passing both parameters, but it works fine when passing just one.
This is the non-working code:
async getFlights(context, { selectedPoint, departurePoint }) {
const res = await fetch(
`http://api.travelpayouts.com/v2/prices/month-matrix?currency=rub&origin=${selectedPoint}&destination=${departurePoint}&show_to_affiliates&token=${context.state.token}`,
);
if (res.ok) {
let result = await res.json();
context.commit('setFlights', result.data);
}
return res.ok;
},
Working code example 1:
async getFlights(context, selectedPoint }) {
const res = await fetch(
`http://api.travelpayouts.com/v2/prices/month-matrix?currency=rub&origin=${selectedPoint}&destination=LED&show_to_affiliates&token=${context.state.token}`,
);
if (res.ok) {
let result = await res.json();
context.commit('setFlights', result.data);
}
return res.ok;
},
Working code example 2:
async getFlights(context, departurePoint }) {
const res = await fetch(
`http://api.travelpayouts.com/v2/prices/month-matrix?currency=rub&origin=LED&destination=${departurePoint}&show_to_affiliates&token=${context.state.token}`,
);
if (res.ok) {
let result = await res.json();
context.commit('setFlights', result.data);
}
return res.ok;
},