I am fetching some data from WP REST API in Next.js with <a href="https://www.npmjs.com/package/isomorphic-unfetch" rel="nofollow noreferrer">Isomorphic unfetch</a>, how can I get response headers?
I don't see anything available in the console <a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>
but headers are there when I just open <a href="https://wordpress.org/news/wp-json/wp/v2/posts" rel="nofollow noreferrer">url</a> in browser <a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>
Code:
import fetch from 'isomorphic-unfetch';
class Blog extends React.Component {
static async getInitialProps() {
const res = await fetch('https://wordpress.org/news/wp-json/wp/v2/posts');
const data = await res.json();
return {
res: res,
data: data
};
}
render() {
console.log(this.props.res)
console.log(this.props.data)
return (
<h1>Blog</h1>
)
}
}
I don't see anything available in the console <a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>
but headers are there when I just open <a href="https://wordpress.org/news/wp-json/wp/v2/posts" rel="nofollow noreferrer">url</a> in browser <a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>