How can I use axios in lambda?

岁酱吖の 提交于 2019-12-10 19:16:02

问题


Do I have to install the axios module locally and then deploy it to lambda or is there a way to do it through the inline code editor as well in the browser?


回答1:


Lambda doesn't actually bundle your package dependencies for you, except the AWS package, so yes you'd need to install it locally, zip it together and upload to the Lambda console.




回答2:


In the folder where your lambda script is present (index.js) run following command -

npm install axios

You should see node_modules directory getting created in the same directory as index.js. Now zip both these together (index.js and npm_modules) and upload it you your lambda as zip. You can repeat this with other npm module dependencies you have. If you do not want to repeat these manual steps again for each module create package.json file and add all your module dependencies there and just run npm install once.



来源:https://stackoverflow.com/questions/48356841/how-can-i-use-axios-in-lambda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!