Amadeus Self Service API making a post request

111 views Asked by At

I am trying to make a post request to Amadeus Self Service API but I am receiving the error below. I hope someone can help me.

Uncaught (in promise) FetchError: [POST] "http://localhost:2801/flight-offers/upselling": <no response> Failed to fetch at async $fetch2 (ofetch.00501375.mjs?v=b3021059:261:15) at async submitBrandedOffers (upselling.vue:25:20)

Server

app.post(`/flight-offers/upselling`, (req, res) => {
  const flight = req.body.flight;
  amadeus.shopping.flightOffers.upselling
    .post(
      JSON.stringify({
        data: {
          type: 'flight-offers-upselling',
          flightOffers: [flight],
        },
      })
    )
    .then(function (response) {
      res.send(response.result);
    })
    .catch(function (response) {
      res.send(response);
    });
});

Template

const offer = route.query.offer_id;
async function submitBrandedOffers() {
  const response = await $fetch(
    'http://localhost:2801/flight-offers/upselling',
    {
      method: 'POST',
      mode: 'cors',
      cache: 'no-cache',
      credentials: 'same-origin',
      headers: {
        'Content-Type': 'application/json',
      },
      redirect: 'follow',
      referrerPolicy: 'no-referrer',
      body: JSON.stringify(offer), 
    }
  );
  // console.log(response.json());
  return await response.json();
}
submitBrandedOffers();

I am unable to get a response and I think I am not accessing the server.

0

There are 0 answers