在所有过程之后,我都得到了预期的响应,但是失败了,错误为cant set header after they are sent
main.ts
export class GetAccountBalanceController extends Controller {
public static async process(@Request() request: ExpressRequest,
response: ExpressResponse): Promise<any> {
try {
const instance = new GetAccountBalanceController();
const data = await instance.execute(request, response);
response.status(200);
response.send(data);
} catch (err) {
response.status(200);
response.send(err.message);
}
}
}
答案 0 :(得分:1)
您将要在“发送”后面附加状态,并且应该为您清除该状态!我也将状态更改为400 :)希望这会有所帮助!
try {
const instance = new GetAccountBalanceController();
const data = await instance.execute(request, response);
response.status(200).send(data);
} catch (err) {
response.status(400).send(err.message);
}