-
Notifications
You must be signed in to change notification settings - Fork 417
Closed
Description
Suppose I want to use a third party lib such as axios
how do I go about doing that?
If I import * as axios from "axios";
then run sls webpack serve
I get the following error:
ReferenceError: XMLHttpRequest is not defined
at dispatchXhrRequest (C:\Projects\Experiments\my-third-service\.webpack\handler.js:1045:24)
at xhrAdapter (C:\Projects\Experiments\my-third-service\.webpack\handler.js:1037:11)
at process._tickDomainCallback (internal/process/next_tick.js:129:7)
If I include axios
in the externals of webpack.config.js:
externals: [
'axios'
],
The code runs but after sls deploy
I get the following error when I try to run the function:
{"errorMessage":"Cannot find module 'axios'","errorType":"Error","stackTrace":["Module.require (module.js:353:17)","require (internal/module.js:12:17)","Object.<anonymous> (/var/task/handler.js:132:19)","__webpack_require__ (/var/task/handler.js:20:30)","Object.<anonymous> (/var/task/handler.js:51:14)","__webpack_require__ (/var/task/handler.js:20:30)","/var/task/handler.js:40:18","Object.<anonymous> (/var/task/handler.js:43:10)"]}
Any ideas? Perhaps an example that uses a third party lib would be good?
Metadata
Metadata
Assignees
Labels
No labels