Reputation: 15
I am working on a firebase project and want to make the webhook target URL my function. The issue is is that I cannot seem to simply print the contents of the json file on the page when I run the URL in my browser. I know the basics of HTTP on firebase but am looking for something to help further. I either get an empty array or an error that the request could not be handled. I've tried numerous different ways but for simplicity, I will comment out a basic version. Yes, I know this is not even close to correct on this super basic version but I thought rather than post my ridiculous efforts to bypass circular structures and the such, I would let someone else take a swing. Again, my only goal is to simply see the data from the webhook on the page.
exports.test = functions.region('europe-west1').https.onRequest((request, response) => {
response.send(request.body)
});
Upvotes: 0
Views: 88
Reputation: 404
One way that you can read the data from the request according to this documentation is doing the following
exports.date = functions.https.onRequest((req, res) => {
// Reading date format from URL query parameter.
// [START readQueryParam]
let format = req.query.format;
// [END readQueryParam]
// Reading date format from request body query parameter
if (!format) {
// [START readBodyParam]
format = req.body.format;
// [END readBodyParam]
}
// [START sendResponse]
const formattedDate = moment().format(`${format}`);
functions.logger.log('Sending Formatted date:', formattedDate);
res.status(200).send(formattedDate);
// [END sendResponse]
});
});
this code is an example of getting the format of a day and send it back to the client.
you can also check the different ways to read information from the HTTP response here.
I hopes this help you in your issue
Upvotes: 1