Amadeus Hotel Search API (Self-Service APIs) with GCP Cloud Functions

73 views Asked by At

I'm using Amadeus Hotel Search API which is one of the their Self Service APIs for my React.js app. With deployment of Cloud Functions in GCP, there is a problem.

  1. Test deployment: this is working well.
const {onRequest} = require("firebase-functions/v2/https");
const {logger} = require("firebase-functions");

exports.helloWorld = onRequest({maxInstances: 10}, (request, response) => {
  logger.info("Hello logs!", {structuredData: true});
  response.send("Hello World!!");
});

However, second one is not working.

  1. Deployment of function with Amadeus Hotel Search API
const {onRequest} = require("firebase-functions/v2/https");
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: process.env.AMADEUS_CLIENT_ID,
  clientSecret: process.env.AMADEUS_CLIENT_SECRET,
});

exports.hotelOffersSearch = onRequest({maxInstances: 10}, async (req, res) => {
  try {
    const response = await amadeus.shopping.hotelOffersSearch.get({
      hotelIds: "RTPAR001",
      adults: "2",
    });
    console.log(response.data);
    res.status(200).send(response.data);
  } catch (error) {
    console.error(error);
    res.status(500).send(error.message);
  }
});

Below is a part of error message when i tried to deploy second one in command.

functions: creating Node.js 18 (2nd Gen) function hotelOffersSearch(us-central1)... Could not create or update Cloud Run service hotelofferssearch, Container Healthcheck failed. Revision 'hotelofferssearch-00001-tox' is not ready and cannot serve traffic.
The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.

And, If I try a request on command, it's working well like this.

enter image description here

What's wrong with me? I think, it's about Amadeus api issue because first test version was deployed successfully.

I'm a beginner, so please explain it in an easy way to understand.

Deployment of HTTP request function in Cloud Functions with Amadeus api

0

There are 0 answers