[英]Serverless-offline - API REST node typescript
I created a project serverless and I am having a trouble:我创建了一个无服务器项目,但遇到了麻烦:
sls create --template aws-nodejs-typescript
npm install serverless-offline --save-dev
then, inside the file serverless.ts I add in:然后,在文件 serverless.ts 中添加:
plugins: ['serverless-webpack', 'serverless-offline'],
So I run the project with the command:所以我使用以下命令运行项目:
serverless offline --stage dev
As response I have:作为回应,我有:
**POST | http://localhost:3000/dev/hello
POST | http://localhost:3000/2015-03-31/functions/hello/invocations**
The request with POST http://localhost:3000/dev/hello using body {“name”: “Andre”} don´t answer, I don´t know why the project don´t response to the request, it only show “sending request” in postman and keeps showing this. POST http://localhost:3000/dev/hello 使用 body {“name”: “Andre”} 的请求不回答,我不知道为什么项目不响应请求,它只显示postman 中的“发送请求”并不断显示。 But if I use the address GET http://localhost:3000 I have a response saying that existing routes are:
但是,如果我使用地址 GET http://localhost:3000 我有一个回复说现有的路线是:
{
"currentRoute": "get - /",
"error": "Serverless-offline: route not found.",
"existingRoutes": [
"post - /dev/hello"
],
"statusCode": 404
}
Please, could you make this process?请问,你能做这个过程吗? I Think there is a bug in the template that was created
我认为创建的模板中存在错误
Thank you.谢谢你。
The problema was the version of nodejs.问题是nodejs的版本。
I was usgin node 16.我是usgin节点16。
Now I am using node LTS 14.现在我正在使用节点 LTS 14。
Problem solved.问题解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.