在我的ANGLE/Express.js应用程序中,我的api.service.ts
文件中有一个POST方法:
post(data: any, endpointUrl: string): Observable<T> {
console.log("REACHED POST METHOD")
return this.http.post<T>(`${this.apiUrl}/${endpointUrl}`, JSON.stringify(data), this.httpOptions)
}
它向我的index.js
文件中的路由处理程序发送POST请求.以下是index.js
份报告的内容:
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
const app = express();
const port = 3000;
app.use(cors());
app.use(bodyParser.json());
app.post('/submit', (req, res) => {
console.log("REACHED ROUTE HANDLER")
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
按钮触发此API调用.POST方法和路由处理程序最初都按其应有的方式工作,但是,在第十次按下按钮后,POST方法仍然运行,但不调用路由处理程序.
我可以呼叫端点的次数是否有内在限制?出于调试目的,我极大地简化了POST方法和路由处理程序,并try 实现try/Catch来捕获可能的错误,但无济于事.我还在POST方法返回语句中记录了每个参数,以确保没有任何未定义的项.