Firebase cloud function http request to another firebase cloud function

I have a basic cloud firebase function with basic functions. But I need to create another feature that uses the functionality of the main function of the cloud. Can I request an HTTP message or Get from one firebase cloud function another firebase cloud function with a free account?

I tried to do this, but I got the message "ENOTFOUND", I want to know something is wrong with my code, or it's just a limitation of a free account.

index.js
'use strict';
const functions = require('firebase-functions');

const express = require('express');
const app = express();

app.post('/test', function(req, res) {
    var request = require('request')

    var options = {
      method: 'post',
      body: req.body, // re-send the incoming body to the main cloud function
      json: true, 
      url: '<main cloud url>',
      headers: req.headers // re-send the incoming headers the main cloud function
    }
    request(options, function (err, response, body) {
      if (err || response.statusCode != 200) {
        res.status(400).send(err); //re-send the received error to the client
        return
      }
      res.send(body); //re-send the received response to the client
    });
});

exports.checkAtivation = functions.https.onRequest(app);
+4
source share
1 answer

Spark HTTP HTTP. Blaze.

, HTTP. , , .

+5

Source: https://habr.com/ru/post/1681782/


All Articles