我的 WIX 网站中有以下功能,它向外部 API 发出请求:
export function current_pull(page, per_page, filter_mode, view_id) {
const url_request = URL + page + '&per_page=' + per_page + '&filtermode=' + filter_mode + '&view_id=' + view_id;
return fetch(url_request, {
method: 'get',
headers: {
'X-AUTH-TOKEN': API_KEY,
'X-SUBDOMAIN': SUBDOMAIN
},
}).then(function(response) {
if (response.status >= 200 && response.status < 300) {
console.log("current answered");
var items = response.json();
console.log(items);
} else {
console.log("there was an error" + response.statusText);
}
})
.catch( (err) => {
console.log(err);
});
}
console.log(items);
输出:
Promise {
_c: [],
_a: undefined,
_s: 0,
_d: false,
_v: undefined,
_h: 0,
_n: false }
如何获得实际的 API 响应