WIX API响应

我在维克斯的网站,这使得外部API的请求以下功能: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响应

回答:

response.json()也是Promise所以在这种情况下,您需要更改您的代码,如下所示:

response.json().then(items => console.log(items)) 

您可在此进一步检查文档:Body.json()

以上是 WIX API响应 的全部内容, 来源链接: utcz.com/qa/260375.html

回到顶部