Next () after successful koa jwt verification, but the value cannot be returned in the controller.

I am doing token verification. Only after successful verification can I continue to pull data. But now I can pull data in the controller after successful verification, but I cannot return the error 404 to the client.

here is the code:
1.jwt Code:

const requireAuth = (ctx, next) => {

const token = ctx.request.headers.authorization
console.log ("passing token"+token);
if (token) {

jwt.verify(token, jwtSecret, function(err, decoded) {
  if (err) {
    console.log(""+err.message);
    if (err.name === "TokenExpiredError") {
      ctx.body={
        status:400,
        msg:"!"
      }
    } else {
      ctx.body={
        status:401,
        msg:"!"
      }
    }
  } else {
    console.log(decoded);
    if (decoded.username ) {
      next()
    } else {
      ctx.body = ""
    }
  }
})

} else {

return ctx.body = ""

}
}

2. The code in the controller:
exports.index = async (ctx) = > {
console.log (ctx);

console.log("");
const {
    userId
} = ctx.query
console.log(userId)
const bankcards = await BankCard.find({
    userId
})
console.log(bankcards);
if (bankcards) {
  console.log("");
    ctx.body = {
        status: 200,
        bankcards
    }
} else {
  console.log("");
    ctx.body = {
        status: 406,
        msg: ""
    }
}

}

backend terminal prompt:
query bank card
i828xTq5b6xMPY3eG
(node:13662) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .cards () is deprecated
--> GET / bankcards?userId=i828xTq5b6xMPY3eG 404 22ms-
[{userId: "i828xTq5b6xMPY3eGateway,

realName: "xxx",
accountNumber: "62215xxxxxxxxx56030",
bankAddress: "xxxx",
createdAt: 2017-08-21T07:37:48.828Z } ]

obtained successfully

client console:
GET http://192.168.31.7:3001/bankcards?userId=i828xTq5b6xMPY3eG 404 (Not Found)
request.js?b775:68 errError: Request failed with status code 404
createError.js?2d83:16 Uncaught (in promise) Error: Request failed with status code 404

at createError (createError.js?2d83:16)
at settle (settle.js?467f:18)
at XMLHttpRequest.handleLoad (xhr.js?b50d:77)







Feb.15,2022

Please format the code.
at a glance, you use koa instead of async + await , but write jwt.verify logic in the callback way of express ? These two incompatible writing methods

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3f110-447e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3f110-447e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?