A Vue.js project using netlify lambda
- first create a vue project
vue init webpack netlambda - second
yarn add -D netlify-lambda - third
code . - create folder in
srccalllambdaor anything else - add
hello.jsand create a handler - add labda script to package json
"lambda":"netlify-lambda serve src/lambda" yarn run lambdacheck the function on 9000- add a button to call the function
- resolve CORS
- go to
configfolder and add a proxy toconfig/index.jsunderdev -
// proxy all requests starting with /api to jsonplaceholder "/.netlify/functions/": { target: "http://localhost:9000/", changeOrigin: true, pathRewrite: { "^/\\.netlify/functions/": "" } } }``` - then in function call
fetch("/.netlify/functions/hello")
.then(r => r.text())
.then(d => {
this.msg = d;
});# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --reportFor a detailed explanation on how things work, check out the guide and docs for vue-loader.