Home>

I want to do an HttpRequest in a CloudFunctions function and receive a response.

Language used: TypeScript

Problem i am experiencing

I tried using XMLRequest,

XMLHttpRequest is not defined
The log is displayed as

.
Apparently XMLHttpRequest seems to be a built-in object in the web browser, but
If so, what library to use
Can I make an HttpRequest in a CloudFunctions function and receive a response?

I don't know how to solve it.

Someone could teach me a solution?
Thanks for your cooperation.

  • Answer # 1

    You can write it normally using fetch
    You may use the following library
    https://www.npmjs.com/package/axios

    Note that if the Firebase project is a free plan, requests outside of Google will not be thrown, so let's change to a pay-per-use plan such as Blaze
    As described in Cloud Functions' outbound networking
    https://firebase.google.com/pricing?hl=en