#Error while fetching api with different origin
35 messages · Page 1 of 1 (latest)
You can't?
also
const req = await fetch(URL).then (res => {
return res.json ();
})```
But it works for this guy https://youtu.be/5miHyP6lExg?t=27903
Discord for any problems/errors/bugs: https://www.codewithantonio.com/discord
Github & Live Website: https://www.codewithantonio.com/projects/ecommerce
In this video, we will put a special emphasis on the Next.js 13 App Router, which is the latest addition to the Next.js framework.
The Next.js 13 App Router is a powerful tool that enables you...
Why are you attempting to get the data from port 3001, which is an unexistent port?
Im not. I'm fecthing from port 3000 which does exist, into the store at 3001
Watch the video at that timestamp. That's what i'm trying to do
Can you send navbar.tsx
I can also give the whole github repo
No
Ok
Nevermind, it's ok lol
I don't think that's where the is issue tho. I think it's response from the fetch. I'm passing the categories which are null, and it's giving me an error because it can't map trought null
There is something wrong within the response ig
are you sure you don't want the whole repo?
Yeah
I mean, feel free to send it
Since it can be useful for looking through files without you having to post anything
Does the API return something?
Yes for sure
If i go to the url i get this
[{"id":"1997d654-c99c-48ab-8aeb-afe7deeb5736","storeId":"97031b30-3c0f-46e5-9ef8-f760012e6f32","billboardId":"6337c632-4266-4b25-b219-9e0e185d2ef3","name":"Glasses","createdAt":"2023-07-23T13:30:43.285Z","updatedAt":"2023-07-23T13:33:38.706Z"},{"id":"19f6cbaf-fc22-4901-92f4-5e148ee89a23","storeId":"97031b30-3c0f-46e5-9ef8-f760012e6f32","billboardId":"eb408522-ecda-4440-9f90-87f2cc04feaa","name":"Shirts","createdAt":"2023-07-22T08:35:30.797Z","updatedAt":"2023-07-22T16:39:47.361Z"},{"id":"226f58bc-f5b3-4bd2-a097-51c7228cbb04","storeId":"97031b30-3c0f-46e5-9ef8-f760012e6f32","billboardId":"88da43c2-f931-4ee1-bba7-329a7fa7147e","name":"Shoes","createdAt":"2023-07-22T08:35:13.440Z","updatedAt":"2023-07-23T08:56:27.122Z"},{"id":"9f05705c-ad6e-4692-9eaf-7f107d97addc","storeId":"97031b30-3c0f-46e5-9ef8-f760012e6f32","billboardId":"183b66d7-f1b1-4cb2-b612-2af074895c37","name":"test","createdAt":"2023-07-27T08:59:42.832Z","updatedAt":"2023-07-27T08:59:42.832Z"}].
mhm.
It returns a object[].
It can be a problem within your file extension?
In the video is get-categories.tsx, while your file extension is just typescript.
But this does not seem to be the issue;
I have a slightly different folder structure. I don't think any of has to do with the issue
No, it isn't