When it comes to fetching data i usually use SWR because it's easy-to-use package, but this time i wanted to fetch data using getServerSideProps or getStaticProps, And of course i tried to use SWR inside them.
But as you know, you can't use it inside those functions because it depends on useContext
hook, if my memory serves me correctly.
Whatever the case, I used Axios - some cases the native fetch function - but now I've got no clue how to handle the loading status of the fetched data or what to do if something went wrong while fetching.
could anyone tell me, how to get these functions using wethier axios()
or fetch()
?
THANK YOU SO MUCH ❤