firebase cloud function post request body

Discussão em 'Angular' iniciado por Giannis Savvidis, Dezembro 15, 2024.

  1. I am making an http request from an angular form like that:

    this.http.post(this.endPoint, formData, { responseType: 'text' }).subscribe(
    res => {
    console.log(res);
    }
    )


    And I have a simple cloud function:

    const functions = require('firebase-functions');
    const cors = require('cors')({ origin: true });

    exports.test = functions.https.onRequest((req, res) => {

    cors(req, res, () => {
    const data = req.body;
    res.send(`Hello from Firebase! ${data}`);
    });

    })


    However the req.body does not work and i get this response :


    Hello from Firebase! [object Object]
    ​

    Is there any idea why this happens?

    Continue reading...

Compartilhe esta Página