微信小程序request请求后端数据返回undefined是什么原因

报错:
图片说明

detail.js

onLoad: function (options) {

let _id = options._id;
console.log("详情页接收的_id值:" + _id);

//请求文章详情页
wx.request({
  url: 'http://localhost/home.html?_id=' + _id,

  headers: {
    'Content-Type': 'application/json'
  },

  success: function(res) {
    let content = res.data.content;
    console.log("文章详情页如下:")
    console.log(content);
  }
})
},

detail.wxml

<text>{{content}}</text>

本地数据:
图片说明

已解决,是请求的路径写错了

res也是undefined吗?如果是的话,你试试你的url是否正确,有没有报错

看一下你后台返回数据的方法,应该是后台存储数据的方式不对导致你在js中取不出来。

数据接口后台返回的结构格式不对吧

点开Network看返回什么

看下浏览器得返回值。debugger一下

res.data[0].content 这样是拿第一条数据吧,是一个数组集合