I used Google Apps Script with
var response = UrlFetchApp.fetch(url, params);
to get a response from an api. Sadly its too many request and
request supports callback interfaces natively but does not return a promise, which is what you must do within a Cloud Function.
You could use request-promise (https://github.com/request/request-promise) and the rp(...) method which "returns a regular Promises/A+ compliant promise" and then do something like:
const rp = require('request-promise');
exports.getCheckfrontBookings = (req, res) => {
var options = {
uri: 'https://fpronline.checkfront.com/api/3.0/item',
headers: {
Authorization: 'Basic ' + Buffer.from('blabla').toString('base64')
},
json: true // Automatically parses the JSON string in the response
};
rp(options)
.then(response => {
console.log('Get response: ' + response.statusCode);
res.send('Success');
})
.catch(err => {
// API call failed...
res.status(500).send('Error': err);
});
};