For more information, the ajax request sent by vue-resource is always nill.

Source: Internet
Author: User
For more information, please kindly advise, when I use vue-resource for ajax requests, the response is always null, and JQuery requests can respond normally, {code ...}

For more information,
When I use vue-resource for ajax requests, the response is always null, while the JQuery request can respond normally,

Created: function () {var vm = this; $. get ('/A', function (data) {vm. list = data;}); // JQuery requests this. $ http. get ('/A', function (data) {vm. list = data;}); // Vue-resource Request },

Reply content:

For more information,
When I use vue-resource for ajax requests, the response is always null, while the JQuery request can respond normally,

Created: function () {var vm = this; $. get ('/A', function (data) {vm. list = data;}); // JQuery requests this. $ http. get ('/A', function (data) {vm. list = data;}); // Vue-resource Request },

Vue. http. options. emulateJSON = true

@ Alimama, but adding this sentence does not work ,,
After reading it, what it receives isResponse {url = "/a", OK = true, status = 200, more ...}Such an object.
In this way, I can access it normally.

`this.$http.get('/a').then(({data})=>{                    vm.list = data;                    console.log(data);                },(data)=>{                    console.log(data);                })`

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.