You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I cannot figure out how I can fetch API data in Next.js project.
I tried to fetch in componentDidMount() because I also use Geolocation API and I need to use window object and in Next.js project, I can only access window object in componentDidMount() ( is it my stereotype?).
I can fetch successfully. However, I need to use longitude and latitude values from geolocation API and geolocation API need window object so I only can get these values in componentDidMount(). How I can fetch Google Map API in componentDidMount() ???
The text was updated successfully, but these errors were encountered:
Question about Next.js
I use React.js + Next.js.
I wanna fetch google map API in this project.
However, I cannot figure out how I can fetch API data in Next.js project.
I tried to fetch in componentDidMount() because I also use Geolocation API and I need to use window object and in Next.js project, I can only access window object in componentDidMount() ( is it my stereotype?).
This is my fetching code.
However, this code does not work. The error message said "formatted_address is not undefined" .
So, I go back to Next.js docs and I found getInitialProps(). When I write code like this
I can fetch successfully. However, I need to use longitude and latitude values from geolocation API and geolocation API need window object so I only can get these values in componentDidMount(). How I can fetch Google Map API in componentDidMount() ???
The text was updated successfully, but these errors were encountered: