Wie man den Koa-HTTP-Antwortcode setzt
English
Deutsch
Um den HTTP-Antwortcode mit Koa zu setzen, verwenden Sie ctx.status = ...
koa_status.ts
ctx.status = 403;Vollständiges Beispiel:
koa_example.js
const Koa = require("koa");
const app = new Koa();
app.use(async (ctx, next) => {
ctx.status = 403;
ctx.body = "Forbidden";
});
app.listen(3000);Check out similar posts by category:
Javascript, NodeJS
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow