Calling Google AppScript web app from cloud functions for Firebase
I am trying to get my cloud functions for Firebase to call a simple web app deployed with Google Apps Script. Can someone point to some example or help figure out what is the cause of the error in my code below. I really appreciate your help.
-
I've created a simple webapp with Google Apps Script.
function doGet() {
return ContentService.createTextOutput('Hello world');
}
And I am calling this using request-request in my Firebase Cloud Function. I tried to be as close as possible to the Google Translate example listed for cloud features. However, I am getting the following error when calling the Cloud function.
RequestError: Error: getaddrinfo ENOTFOUND script.google.com
script.google.com:443
Here is my cloud function code -
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const request = require('request-promise');
exports.makeUppercase =
functions.database.ref('/users/{userid}/logs/{logid}/mykey')
.onWrite(event => {
var url = `https://script.google.com/macros/s/.../exec`;
var retstr = request(url, {resolveWithFullResponse: true}).then(
response => {
if (response.statusCode === 200) {
const data = response.body;
return event.data.ref.parent.child('uppercase').set(data);
}
throw response.body;
});
});
Thanks in advance,
Rahul's relationship
source to share
I had the same problem and found this answer ( fooobar.com/questions/359564 / ... ). It looks like the call to Google Apps Script is considered external.
source to share