Skip to content

Commit

Permalink
fix(express): json content reading error
Browse files Browse the repository at this point in the history
  • Loading branch information
ephrimlawrence committed Jul 28, 2024
1 parent 900c2d5 commit 429d3fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/app.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Ananse {
const data = req.body;

try {
if (req.headers["content-type"] === "application/json") {
if (req.headers["content-type"] != null && req.headers["content-type"]?.indexOf("application/json") > -1) {
request.body = data;
}
// TODO: parse other content types
Expand Down
4 changes: 2 additions & 2 deletions src/core/request_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,15 @@ export class RequestHandler {
}

private async resolveGateway(stage: "request" | "response") {
if (stage == "request") {
if (stage === "request") {
const item = new this.config.gateway(this.request, this.response);
const _state = (await item.handleRequest(this.request, this.response))!;
await this.session.setState(_state.sessionId, _state)!;

return _state;
}

if (stage == "response") {
if (stage === "response") {
const item = new this.config.gateway(this.request, this.response);
await item.handleResponse(this.request, this.response);
}
Expand Down

0 comments on commit 429d3fa

Please sign in to comment.