我正在尝试使用 axios 从 api 获取数据,response.data
是空数组。这是我的代码。(邮递员一切正常)
const serviceApiClient = () =>
axios.create ({
baseURL: Config.BASE_URL,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
timeout: 3000,
});
function getAll (payload) {
return serviceApiClient ()
.get ('/list' , payload)
.then ((response) => {
console.log(response.data)
return response.data;
})
.catch (function (error) {
return null;
});
}