xxx POST /user/register 500 368ms - ....cannot be an array or an object
这个错基本都是在async函数里少些了异步操作,需要补上一些await
才行
await 表示在这里等待promise或者等待async函数中的promise返回结果了,再继续执行。
给几个例子:
在controllers–>user_controller.js里使用:
// 注册新用户
const register = async(ctx,next) => {
ctx.status = 200 // post 默认是404
const req = ctx.request.body
const user_name = req