How to send a HTTP request from Google Cloud Functions (nodeJS)

后端 未结 5 1249
无人共我
无人共我 2020-12-29 06:33

This is probably a simple question but I\'m new to cloud functions/Node programming and haven\'t found the right documentation yet.

How do I write a Google cloud f

5条回答
  •  一整个雨季
    2020-12-29 06:48

    Use https://www.npmjs.com/package/request module.

    var request = require('request');
    request.get('https://maker.ifttt.com/trigger/arrive/with/key/xxxx', function (error, response, body) {
      console.log('error:', error); // Print the error if one occurred 
      console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received 
      console.log('body:', body); //Prints the response of the request. 
    });
    

提交回复
热议问题