I am trying to use axios in Functions. The package installs successfully but when I want to use it, I get following errors. I installed the latest axios version. But which version is NodeJS within Functions? Or what am I missing?
failed to execute source for 'node_modules/axios/index.js': FunctionError: failed to execute source for 'node_modules/axios/lib/axios.js': FunctionError: failed to execute source for 'node_modules/axios/lib/core/Axios.js': FunctionError: failed to execute source for 'node_modules/axios/lib/core/dispatchRequest.js': FunctionError: failed to execute source for 'node_modules/axios/lib/adapters/adapters.js': FunctionError: failed to execute source for 'node_modules/axios/lib/adapters/http.js': TypeError: Cannot access member 'Z_SYNC_FLUSH' of undefined
at node_modules/axios/lib/adapters/http.js:36:10(187)
at require (native)
at node_modules/axios/lib/adapters/adapters.js:16:44(41)
at require (native)
at node_modules/axios/lib/core/dispatchRequest.js:20:48(77)
at require (native)
at node_modules/axios/lib/core/Axios.js:18:55(63)
at require (native)
at node_modules/axios/lib/axios.js:17:45(51)
at require (native)
at node_modules/axios/index.js:22:45(73)
App Services Functions don’t run in a Node.js process, but in a specific environment that emulates, as close as possible, Node.js v10, so it’s very likely that the latest axios package wouldn’t be compatible.
Have you tried older versions? Some users have reported v1.2.0 as working, YMMV.
what is the correct way to make requests? if i try to use “fetch” the response is “fetch is not define” and with axios 1.2.0 the response if i try to make a request with "await axios.get(“url”) is
error:
{“message”:"‘get’ is not a function", “name”: “TypeError”}
Which version of axios have you uploaded as dependency? As specified above, the sample code I provided works for 1.2.0, other versions may not work within the current Function environment.