I've setup a Firebase function for a Google action with Dialogflow that makes an API call using node-fetch
but I'm running into problems when I make the actual request. Even though I can visit the URL in the browser, I'm not able to get it to resolve when my function runs.
Error:
{"message":"request to https://jsonplaceholder.typicode.com/users failed, reason: getaddrinfo ENOTFOUND jsonplaceholder.typicode.com jsonplaceholder.typicode.com:443","type":"system","errno":"ENOTFOUND","code":"ENOTFOUND"}
Code:
import * as functions from 'firebase-functions';
import fetch from 'node-fetch';
export const fetchTrainTimetable = async (): Promise<object> => {
const path = `https://jsonplaceholder.typicode.com/users`
try {
const response = await fetch(path, {method: 'GET'});
return await response.json();
} catch (error) {
return error;
}
}
Is there something missing that I need to include in the request in order to make an outbound request with Firebase functions? It doesn't seem to matter what the path is, I always end up with this error.