I'm using Firebase Cloud Function to create an HTTP function. The purpose of this function is to do a POST and return the response. (I use Axios in order to do the POST)
Here is my code:
exports.doHttpPost = functions.https.onRequest((request, response) => {
axios.post(url, data, config)
.then(response => {
console.log(response);
response.status(200).send(response);
})
.catch(error => {
console.log(error);
// --> What should I write here to end the function? <--
});
});
My question is: How can I end the function if the 'axios.post' fails? I correctly finish the 'then' with 'response.status(200).send(response)'. But I don't know how to finish the 'catch'.