Skip to content

Versi 6.x : Cannot destructure property 'XXX' of 'ctx.request.body' as it is undefined. #218

@zgramming

Description

@zgramming

Describe the bug

Node.js version: v18.9.1

OS version: Windows 11 Home Version 22H2

Description:

Actual behavior

Destructure property undefined throw error

image

Expected behavior

It's use version 5

Destructure property undefined not throw error

image

Code to reproduce

 public static async Testing(ctx: ParameterizedContext, next: Next) {
    try {
      const { id, user_id, template_pdf_id } = ctx.request.body;

      ctx.status = 200;
      return (ctx.body = {
        message: "Berhasil mengupdate template PDF",
        // data: upsert,
      });
    } catch (error: any) {
      console.log({ error: error });
      ctx.status = error.code ?? 500;
      return (ctx.body = {
        success: false,
        message: error?.message ?? "Unknown Message Error",
      });
    }
  }

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions