请求中有数据,但axios无法读取

时间:2018-11-23 18:48:28

标签: javascript ajax laravel axios

我正在使用laravel api请求上的axios进行GET请求进行成功 但是我得到的回应是空的 这是当我更改axio的基本URL时的代码

window.axios = require('axios');
window.ajaxHeaders = {
    'X-CSRF-TOKEN': window.Laravel.csrfToken,
    'X-Requested-With': 'XMLHttpRequest'
};
window.axios.defaults.headers.common = window.ajaxHeaders
window.axios.defaults.baseURL="https://roqstaraudio.com/";

这是请求 enter image description here

这是空的回应 enter image description here 当在浏览器上点击相同的URL获取数据时 enter image description here

这是我通过GET Request从ajax调用的URL

https://roqstaraudio.com/api/item/list?categories[0]=2&order[0]=latest&per_page=18&relations[0]=creator

在控制台中获取它 enter image description here

1 个答案:

答案 0 :(得分:0)

那是一个OPTIONS请求,而不是一个GET请求。检查控制台以获取更多信息