How to do Axios request from Firebase Cloud Function

后端 未结 2 1749
没有蜡笔的小新
没有蜡笔的小新 2021-02-08 06:30

I\'ve tried the following in Firebase Cloud Function to do an Axios request but it didn\'t work.

    const functions = require(\'firebase-functions\');
    const         


        
2条回答
  •  不知归路
    2021-02-08 07:15

    I experienced the same issue. An HTTP request with axios returns the following error message : TypeError: Converting circular structure to JSON

    Here is an explanation of what is going on and how to get around this

    You can use the following package : https://github.com/moll/json-stringify-safe

    I'm not sure about the consistency of this approach and personally went for request-promise, which is heavier than axios but allows straightforward HTTP requests.

提交回复
热议问题