Next.js Discord

Discord Forum

app router uses improved fetch? Does it have compatibility with libraries like ky?

Answered
Somali posted this in #help-forum
Open in Discord
SomaliOP
subject
Answered by Somali
first one, change localhost to 127....
View full answer

37 Replies

Yes
@alfon Yes
SomaliOP
thank you. can you send me link on docs where write how to fetching data inside components (header/footer?) please?
@alfon using ky or just fetch?
SomaliOP
fetch
for some reasoon i get error, and i cant google that error
Unhandled Runtime Error
Error: fetch failed
the pages are server component....
@alfon the pages are server component....
SomaliOP
yes, my bad, you understand now what i mean?
uhh not yet, perhaps you can give more info?
@alfon 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)
I know but
where is the error
im befuddled xD
SomaliOP
Unhandled Runtime Error
Error: fetch failed
do you actually have server at :1337?
SomaliOP
if i run code for fetching in console its work good
@alfon do you actually have server at :1337?
SomaliOP
yeah, this strapi
so i think this is something with next js
try console.log(res)
oh
first thing first
where is your <header> used?
@alfon where is your <header> used?
SomaliOP
in layout
@alfon try `console.log(res)`
SomaliOP
nothing
@Somali in layout
layout.tsx?
send screenshot of layout.tsx
@alfon send screenshot of layout.tsx
SomaliOP
@alfon layout.tsx?
SomaliOP
solve it
but why does it work like this...
you solved it?
which one solved your answer?
@alfon 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!