获取API不返回响应

时间:2017-06-07 17:46:26

标签: javascript async-await fetch-api

   async function getQuote() {
  console.log("heya");

  const url = "/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1";

  const response = await fetch(url);

  console.log(response);
  return await response.json();

  // console.log("hello", quote);
}

getQuote().then(result => {
  console.log("here");
  console.log(result.shift());
});

这是我的代码。为什么没有回复的东西?     链接:https://codepen.io/anon/pen/JJYGNJ?editors=1012

0 个答案:

没有答案