Нужно открыть его на сервере без возможности, так как он определяет, что получить все - это не функция?инициализированный getall является serverless.yaml и объявил функцию в handler.js, однако функция не определена в безсерверном компиляторе
service: api
provider:
name: aws
runtime: nodejs6.10 # set node.js runtime
memorySize: 128 # set the maximum memory of the Lambdas in Megabytes
timeout: 10 # the timeout is 10 seconds (default is 6 seconds)
stage: dev # setting the env stage to dev, this will be visible in the routes
region: us-east-1
functions: # add 4 functions for CRUD
create:
handler: handler.create # point to exported create function in handler.js
events:
- http:
path: restaurant # path will be domain.name.com/dev/handler
method: post
cors: true
getOne:
handler: handler.getOne
events:
- http:
path: restaurant/{id} # path will be domain.name.com/dev/handler/1
method: get
cors: true
getAll:
handler: handler.getAll # path will be domain.name.com/dev/handler
events:
- http:
path: restaurant
method: get
cors: true
//handler.js
// Handling incoming get requests to /order
router.get(module.exports.getAll = (req,res,next) => {
Restaurant.find().exec()
.then(docs =>{
console.log(docs);
res.status(200).json(docs);
})
.catch(err => {
console.log(err);
res.status(500).json({
error: err
});
});
});