var jwt = require("jsonwebtoken")
module.exports = async function (ctx, next) {
const token = ctx.request.body.token || ctx.query.token || ctx.request.headers["x-access-token"]
if(token) {
jwt.verify(token, "zhiyuJS", function(err, decoded) {
if (err) {
return ctx.body = { status: 0, msg: "token", err }
} else {
ctx.userinfo = decoded
next()
}
})
} else {
return ctx.body = {
status: 0,
msg: "token"
}
}
}
exports.find = async function (ctx) {
let res = await SpaceModel.find()
console.log(res) //
ctx.body = {
result: res
}
}
but the interface report-- 404