当我向服务器发出请求时,MySQL 返回一个 STRING 对象而不是 JSON。这是模型实例const Task = sequelize.define(task, { name: DataTypes.STRING, questions: DataTypes.JSON})return Task和控制器async index(req.res) { try{ const id = req.params const getTask = await task.findOne( { where: {id: id} }, { raw: true } ) res.send(getTask) } catch(e) {}}如何获取实际的 JSON 数据而不是 STRING?谢谢
1 回答
收到一只叮咚
TA贡献1821条经验 获得超4个赞
您没有解析结果数据。
async index(req,res) {
try{
const id = req.params
const getTask = await task.findOne({
where: {
id: id,
},
})
console.log(getTask)
}
catch(e) {}
}
添加回答
举报
0/150
提交
取消