app router uses improved fetch? Does it have compatibility with libraries like ky?
Answered
Somali posted this in #help-forum
SomaliOP
subject
37 Replies
Yes
@aardani Yes
SomaliOP
thank you. can you send me link on docs where write how to fetching data inside components (header/footer?) please?
@aardani using ky or just fetch?
SomaliOP
fetch
@aardani https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#fetching-data-on-the-server-with-fetch
SomaliOP
thkank you, but i mean inside component . not the pages
for some reasoon i get error, and i cant google that error
Unhandled Runtime Error
Error: fetch failedthe pages are server component....
@aardani the pages are server component....
SomaliOP
yes, my bad, you understand now what i mean?
uhh not yet, perhaps you can give more info?
@aardani uhh not yet, perhaps you can give more info?
SomaliOP
i just wanna get data inside Header component, but i got error.
Im newbie in app router, in pages i waas just use getStaticProps to getData, but someone say me that in app router i can fetch data inside components (not pages)
Im newbie in app router, in pages i waas just use getStaticProps to getData, but someone say me that in app router i can fetch data inside components (not pages)
SomaliOP
Unhandled Runtime Error
Error: fetch failed
Error: fetch failed
do you actually have server at :1337?
SomaliOP
if i run code for fetching in console its work good
@aardani do you actually have server at :1337?
SomaliOP
yeah, this strapi
so i think this is something with next js
@aardani where is your <header> used?
SomaliOP
in layout
@aardani try `console.log(res)`
SomaliOP
nothing
@Somali in layout
layout.tsx?
send screenshot of layout.tsx
@aardani layout.tsx?
SomaliOP
solve it
but why does it work like this...
you solved it?
which one solved your answer?
@aardani which one solved your answer?
SomaliOP
first one, change localhost to 127....
Answer
@Somali first one, change localhost to 127....
ahhh im glad it worked out!