Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
898 views
in Technique[技术] by (71.8m points)

vue-cli 中的proxyTable 请求成功了,但是数据数据未空,怎么回事的呢

( 我请求的接口是thinkphp中的接口,tp接口请求的是node那边的(请假tp接口是获取不到数据的,但是成功了200,数据为null),但是我直接请求node那边的是可以获取到数据的,我怀疑tp这边有问题,但是不知道怎么解决 )

proxyTable: {

  '/api': {
    target: 'http://*********.com/nearby/index.php/Home/NearbyInterface',
    changeOrigin: true,
    pathRewrite: {
      '^/api': ''
    }
  }
},
this.$http.post('/api/showProducts', {openId: 'ohs23uMdqr0s_5T92ssm8PbzqcSg'}).then((response) => {
      console.log(response);
      console.log(JSON.parse(response.body));
    }, (response) => {
      console.log(response);
    });

clipboard.png
我在post接口是没问题的

clipboard.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

thinkphp 后台代码于mysql 数据库操作的,也没反应(链接上了数据库,但是查询返回null)

加上 这个 emulateJSON : true 就可以了

其实还是http协议不懂,是应为请求体的头部,有很多种选择。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...