Important: The request package is no longer supported, as indicated on the npm page request-npm. It's recommended to explore other alternatives like axios
You can achieve this by utilizing the request
module:
// Importing the module
var request = require('request');
// Making the request
request('put your external URL here', function (error, response, body) {
if (!error && response.statusCode == 200) {
// Add your desired actions for handling the request here
}
})
NOTE: This method will only function with premium plans. Utilizing non-Google APIs is not feasible with the free Spark plan, as detailed in the Firebase pricing guidelines:
The Spark plan permits outbound network requests solely to Google-owned services. Inbound invocation requests fall within the quota limits. On the Blaze plan, Cloud Functions offer a perpetual free tier. The initial 2,000,000 invocations, 400,000 GB-sec, 200,000 CPU-sec, and 5GB of Internet egress traffic are provided at no cost each month. Charges apply for usage exceeding this complimentary allotment. Pricing is determined by the total number of invocations and compute time. Compute time varies based on the allocated memory and CPU for a function. Usage restrictions are enforced through daily and 100s quotas. For further details, refer to Cloud Functions Pricing.