Next.js Tutorial #10 - Fetching Data (getStaticProps)

  Рет қаралды 184,953

Net Ninja

Net Ninja

Күн бұрын

Пікірлер: 113
@justfun591
@justfun591 2 жыл бұрын
After watching just first minute of your video, I am your subscriber. Sir!
@ApurvKhare
@ApurvKhare 4 жыл бұрын
Watched all 10 videos in a go 🔥
@ranjeet5806
@ranjeet5806 3 жыл бұрын
koi award do bhai isko
@parsajafari51
@parsajafari51 3 жыл бұрын
shaun I have learned a lot from you it started from basic html css js unitl now that I am a react developer and want to learn Next to build fantastic projects
@kapilyadav9664
@kapilyadav9664 2 жыл бұрын
Brother thank you so much for creating this video. Subha se pareshan ho rha that UI pe data show karane ke wajah se. But aapka video dekh kr ek baar me kaam ho gya.. Thanks for creating this useful video.
@maskman4821
@maskman4821 4 жыл бұрын
getStaticProps function in Nextjs works same as asyncData hook in Nuxtjs, they both works in page component only, do the same thing (fetching data on server side). we can learn Nuxtjs at the same time and compare the differences !!!
@hafsahussein2016
@hafsahussein2016 4 жыл бұрын
hello the net ninja the best youtuber ever for my web development learning journey, I would like javascript design patterns with real life projects, the most of the courses explain them without giving real life projects so please try that
@simply_the_dev7588
@simply_the_dev7588 3 жыл бұрын
export async function getStaticProps() { const exploreData = await fetch("some link").then( (res) => res.json() ); const cardData = await fetch("some link").then((res) => res.json() ); return { props: { exploreData, cardData, }, }; Above is some code from another project showing another way. Maybe this helps others.
@anggurmerah3025
@anggurmerah3025 2 жыл бұрын
thank you sir, my error program map is running.
@frogGames
@frogGames 2 жыл бұрын
thanks this worked
@dmitriystoyanov933
@dmitriystoyanov933 3 жыл бұрын
Thank you, bro! I solved my task with help of this tutorial!
@mjylove2
@mjylove2 6 ай бұрын
finally i understood this concept thank you
@NetNinja
@NetNinja 6 ай бұрын
Great to hear!
@luismuzquiz
@luismuzquiz 3 жыл бұрын
What if the data comes from a local json file on a folder called data?
@jamesaldridge1128
@jamesaldridge1128 2 жыл бұрын
did you figure this out?
@luismuzquiz
@luismuzquiz 2 жыл бұрын
@@jamesaldridge1128 Yeah, long time ago
@sauvikgoel591
@sauvikgoel591 Жыл бұрын
​@@luismuzquiz then let us know that too 🙌
@MerthanMerter
@MerthanMerter 3 жыл бұрын
6:17 how did you fix this error, it does persist on mine?
@Awesometechgamer
@Awesometechgamer 2 жыл бұрын
im having the same Error : (
@penocrat
@penocrat Жыл бұрын
Thanks so much for this lesson, Shaun. You've really been an amazing guide in my programming journey. But I do have a question though. Coming from a cybersecurity background, I like to think of security best practices... I'm somehow concerned about the amount of data we're fetching for each user from the API only to use a single "name" data. I think tools such as "burp suite" can be used to intercept these API requests and all these data would be out there in the open. Even those that aren't intended to be disclosed to the public. How then can we prevent this type of vulnerability? I'm thinking there'd be a way to filter the data returned to us and not the entire data.
@jonkarrer
@jonkarrer 3 жыл бұрын
You are changing lives out here.
@KimCarlos12
@KimCarlos12 Жыл бұрын
You teach from a beginner perspective and keep it simple. You are my best youtube-teacher. If someone like @WebDevSimplified built this tutorial, he would have probably used a database connection and i bet thats where any beginner watching would click out of the video and look for a simpler one. No offense @WebDevSimplified
@Awesometechgamer
@Awesometechgamer 2 жыл бұрын
im getting the error called ( property 'map' of undefined ) please Help : ( I followed everything as it is
@prakharmathur619
@prakharmathur619 4 жыл бұрын
please make more tutorials, I am using next in my internship and it is helping a lot
@jimmypriono7422
@jimmypriono7422 3 жыл бұрын
Ninjas.module.css .single { padding: 2px 16px; background: #fff; display: block; margin: 20px 10px; border-left: 8px solid #fff; } .single:hover { border-left: 8px solid #4979ff; }
@みの-e7j
@みの-e7j 3 жыл бұрын
Good Next.js Movie Contents
@erickgeneric
@erickgeneric 3 жыл бұрын
Hi. Naïve question here: if getStaticProps runs at build time, how are we able to access the data it in development?
@Azro-g3w
@Azro-g3w Жыл бұрын
This is SO cool ❤😊
@esirkings4191
@esirkings4191 3 жыл бұрын
Nice tutorial. How do you handle errors e.g in case that API is unavailable?
@subhasishnath3078
@subhasishnath3078 2 жыл бұрын
Next Doc example: nextjs.org/docs/basic-features/data-fetching/get-static-props#using-getstaticprops-to-fetch-data-from-a-cms
@learnsimple4592
@learnsimple4592 4 жыл бұрын
Simple and easy to understand :) will you be covering getServerSideProps and getStatic Paths in this course ?
@NetNinja
@NetNinja 4 жыл бұрын
Yeah - that's coming over the next couple of videos :)
@apezcodes704
@apezcodes704 3 жыл бұрын
very simple and details God bless. i have search the whole internet for this simple details. please can you make a video on how to build a complete website with nextjs fetching static and dynamic data
@suzanne_atkinson
@suzanne_atkinson Жыл бұрын
Thank you for the great teaching. How is this function different from the useFetch function that you build in your Udemy course? Is this preferred for next, or is this just fora. single page at a time?
@webarrays
@webarrays 2 жыл бұрын
Server Error TypeError: Cannot read properties of undefined (reading 'map') its showing an error and not solving
@muhammadfirmanakbar9696
@muhammadfirmanakbar9696 3 жыл бұрын
awesome tutorial thanks
@coffeefps
@coffeefps 3 жыл бұрын
For the getStaticProps, do we have something like a prop we can get to check if data is fetching? So we can show stuff like a loader/skeleton in the UI to tell the user we are fetching data.
@brucelee7782
@brucelee7782 3 жыл бұрын
4:50 I wonder how does getStaticProps automatically puts the props it returned into the Ninjas function lol. I read the documentation and it just says "populated", whatever that means
@justinlu5730
@justinlu5730 3 жыл бұрын
thats because getStaticProps executes before the component is render and for that reason pass the props to the function somehow.
@brucelee7782
@brucelee7782 3 жыл бұрын
@@justinlu5730 thats not answering the question bro haha
@alejandrocano88
@alejandrocano88 3 жыл бұрын
I believe it needs to build in order to get that data? not sure..
@alexlytle089
@alexlytle089 3 жыл бұрын
New subscriber so much better than brad traversy
@kresnofatihimani8402
@kresnofatihimani8402 3 жыл бұрын
what about listeners like firebase onSnapshot functions? do we put it in the getstaticprops as well? thx 😁
@andante4955
@andante4955 4 жыл бұрын
I recently finished your Udemy JavaScript course Shaun, and it was excellent, thank you. Should I now learn React & Next? Or Vue & Nuxt? Its so confusing? I honestly don't know where to go now?
@NetNinja
@NetNinja 4 жыл бұрын
Hey, well done & thanks :). I would advise learning Vue or React first - these are front-end JS frameworks/libraries for making websites. Once you've done that, dive into Next.js (if you chose React) or Nuxt.js (if you chose to learn Vue). Both of these allow React and Vue to run on the server (SSR).
@Clones1
@Clones1 3 жыл бұрын
Great video I only have one question how do I put in basic Auth agains a api endpoint in next.js keep it up great content
@rachaelmathew5328
@rachaelmathew5328 3 жыл бұрын
Hi, I got the "TypeError: Cannot read property 'map' of undefined" but when I reloaded my page, I still had the error.
@kaylaginger2010
@kaylaginger2010 2 жыл бұрын
same
@lan.__.e
@lan.__.e Жыл бұрын
Did you use the same API as in the video? It should be working I worked with another API which had only one element and had the same problem (makes sense it won't map, cause it's only one object) You should be using API with an array of objects
@ktoscos4546
@ktoscos4546 2 жыл бұрын
getStaticProps need be in component which is in pages folder , I tried do it in component from another my own folder and there doesnt work
@gavquinny
@gavquinny 3 жыл бұрын
Amazing content - ty! :)
@rahulnarayanan778
@rahulnarayanan778 4 жыл бұрын
Awesome tuts!
@NetNinja
@NetNinja 4 жыл бұрын
Thank you :)
@seanpaulson9098
@seanpaulson9098 2 жыл бұрын
why are you exporting the getStaticProps function when its in the same file?
@filip23128
@filip23128 2 жыл бұрын
Thanks!
@BBOXPLANET
@BBOXPLANET 3 жыл бұрын
Why did you use props? Is not UseContext better?
@fariedomar401
@fariedomar401 3 жыл бұрын
i got this error : TypeError: Cannot read property 'map' of undefined
@bishnudas3562
@bishnudas3562 3 жыл бұрын
can you explain why we are exporting getStaticProps function?
@ismetglumcevic7061
@ismetglumcevic7061 4 жыл бұрын
Hi, can we use context to store fetched data like in react? Does it make sense in server rendering?
@mohamedyoussef8835
@mohamedyoussef8835 3 жыл бұрын
Super Awesome Tutorial - thank you ++++++++++++++++++++
@marcinkalmar9964
@marcinkalmar9964 2 жыл бұрын
really really thanks :)
@HrissW
@HrissW 4 жыл бұрын
how do you learn this skill so fast?
@NetNinja
@NetNinja 4 жыл бұрын
It's my full-time job to learn & teach, so it gets easier over time! :)
@HrissW
@HrissW 4 жыл бұрын
Thanks:) can make a vid on how I learned things if possible, it would be helpful for us
@craigroberts4445
@craigroberts4445 2 жыл бұрын
.map is not a function - supposedly the .map function only works for arrays ?
@Mufaqar
@Mufaqar 2 жыл бұрын
How can we use this Ninja Component in other components/pages?
@arthuroyugi2045
@arthuroyugi2045 2 жыл бұрын
hi, what do you do i your map function doesnt work after the refresh?
@anggurmerah3025
@anggurmerah3025 2 жыл бұрын
sorry sir, i got eror in list ninja, when refreshed it doesn't turn into a data list, how?
@remofurrer1011
@remofurrer1011 2 жыл бұрын
How can you fetch the Data from a local file? I can not figure this out. With dynamic routes.
@ashishdhakal4087
@ashishdhakal4087 Ай бұрын
MY 404 page is not automatically reconized , by the app i tried looking up the default 404 templete and edit it, but couldn't find it. Same with page title and Meta data looks like it's automatically fetching from default location instead of reading my code. Possibly because of the newer version , also this version doesn't have index.html and it's directly page.js and layout.js in src folder which makes it a bit harder to follow up with the tutriorial , Need the Suggensitons please
@ogibinedi
@ogibinedi 2 жыл бұрын
what the difference between getServerSideProps, i am getting an error product.map() is not a function
@mrFighter924
@mrFighter924 4 жыл бұрын
Why not axios? Just asking? And why not getServerSideProps? What's the difference?
@amongdoomers9464
@amongdoomers9464 4 жыл бұрын
what if I ask you "why not fetch"?, the reason is simple . This is a next js course and not everyone uses axios so maybe he didn't want to confuse us
@FilipeFreire
@FilipeFreire 4 жыл бұрын
getServerSideProps gets executed at every request, while getStaticProps only gets called at build time. When you have data you expect to change every now and then, use the first. When you expect data to stay "static", then getStaticProps is your friend :) also, fetch is built into javascript, while axios is an external package you'd need to install, which, for the purposes of this tutorial, would be an overkill (at least in my opinion!).
@mrFighter924
@mrFighter924 4 жыл бұрын
@@amongdoomers9464 i came here to learn something, not debating...
@mrFighter924
@mrFighter924 4 жыл бұрын
@@FilipeFreire thank you for your response, time and patience, this helped me a lot...
@amongdoomers9464
@amongdoomers9464 4 жыл бұрын
@@mrFighter924 bruh, I literally tried to make you understand my point🤥
@sauvikgoel591
@sauvikgoel591 Жыл бұрын
How to replicate same thing of we want to re fetch data on certain conditions, like we do in useEffect with dependency array... Pls help
@BrianNelsonFilms
@BrianNelsonFilms 3 жыл бұрын
how would you use this if the data didnt have id's? For example i'm trying to fetch data from an object called food and within that object fruit and within that citrus { "food": { "fruit": { "citrus": "orange" } } } I want to fetch the word orange
@avatr7109
@avatr7109 3 жыл бұрын
what are the resources where i can Put my data and then fetch in My next js application? Like above ?? or should i make custom JSON file and fetch inn
@athulkrishnadiyil1735
@athulkrishnadiyil1735 3 жыл бұрын
how to do in typescript?
@ritikjain3975
@ritikjain3975 2 жыл бұрын
Why i'm getting ERROR when I use getStaticProps "Failed to load SWC" . It works fine when I use usEffect instead.
@kosmedsuporte
@kosmedsuporte 2 жыл бұрын
How can i get some params from the client to my getStaticProps ? e.g: Every time the user change some kind of filter on the front end, my getStaticProps function receive the new parameter and change on the fetch function ?
@mistersir3185
@mistersir3185 3 жыл бұрын
Can you please explain why are we using export, async and await. I am new to these keywords. I have done research on my part, but I'm still not 100% clear.
@bardsnight
@bardsnight 3 жыл бұрын
Watch his tutorial series about Asynchronous Javascript. I'm sure you will leave understanding it way better than before. About export, do you mean ES6 Modules Exports, at the end of a functional component?
@theroastingershow161
@theroastingershow161 3 жыл бұрын
i'm getting map undefined
@ibrahim.3999
@ibrahim.3999 3 жыл бұрын
Make sure you're using async/await or putting end points properly, I hope you've figured it out now since it's been a month.
@mat55336
@mat55336 3 жыл бұрын
Would anyone know why NextJs is giving me the error "banner.map is not a function" I'm somewhat knew doing this stuff and I can't seem to find a fix?
@eotikurac
@eotikurac 2 жыл бұрын
why skip or ignore error handling when fetching data? i know this is a basic tutorial but a project cannot be complete without detailed error handling. this approach just makes beginners think they know what they're doing and that cannot be a good thing.
@carldrogo9492
@carldrogo9492 Жыл бұрын
You should NOT be building Apps with meta-frameworks if you are a begginner. 🤡
@Guest-nb8se
@Guest-nb8se Жыл бұрын
some of peoples get error in map method error: we cant map sth that is undifined sth like that if you get this error you cant do anything this erorr is becose of your next js versian you shode delete your project and make a new one but not like this (npx create-next-app filename) if you make like this you get error write this (npx create-next-app@latest filename) when you add @latest you get the last version
@pavankumargvs5693
@pavankumargvs5693 4 жыл бұрын
How can I use redux along with getstaticprops?
@mihaimyh
@mihaimyh 4 жыл бұрын
How to handle authenticated API calls in this case?
@seymurmammadov3868
@seymurmammadov3868 2 жыл бұрын
I get the error failed to fetch for some reason
@nishantraoguvvada
@nishantraoguvvada 5 ай бұрын
Does this still work? I'm getting this error: "getStaticProps" is not supported in app/." Apparently, there's been an update to the way one can have SSG but there's no documentation of how. Anyone knows a workaround?
@DarylsWorld
@DarylsWorld 2 жыл бұрын
How to sort Name based on id?
@nicolasfranco77
@nicolasfranco77 2 жыл бұрын
map function doesnt work after the refresh? Solution: " I was trying to use getStaticProps in a component archive, it need to be used in a page... Thanks everyone." (stackoverflow)
@allmdp
@allmdp 3 жыл бұрын
Best bro
@rodrigo-tj1gf
@rodrigo-tj1gf Жыл бұрын
javascript and typescript syntax completely destroy me. so much () and {} and arrow functions that i never have any idea how to do anything
@CryptoZombie666
@CryptoZombie666 Жыл бұрын
exactly, never faced such issues in other languages.
@kaduzinhoba
@kaduzinhoba 4 жыл бұрын
I don't what happens... but my map is not working... ' undefined '
@mistersir3185
@mistersir3185 3 жыл бұрын
use Waze app if you're driving. Google map can be confusing when you're driving.
@alphaxchanberg5359
@alphaxchanberg5359 3 жыл бұрын
You can only use getStaticProps on pages (files in the /pages directory), not in regular React components. I suggest you get the posts in your pages/index.js file and pass them as props to the FeaturedPosts component.
@markokafor7432
@markokafor7432 4 жыл бұрын
Nice tuts!!! You should implement a check first next time like this. ninja && ninja.map( ...)
@kakashi3966
@kakashi3966 2 жыл бұрын
I don't know how component Ninjas can detect a function getStaticProps ???
@VMzaVAS
@VMzaVAS 4 жыл бұрын
Best!
@sarahabib9338
@sarahabib9338 11 ай бұрын
King
@ridl27
@ridl27 4 жыл бұрын
ez :D ty.
@incognitohacks4850
@incognitohacks4850 4 жыл бұрын
Programming teacher: Lets learn some Next.js Me: You need to go watch the Het Ninjas Videos noob😎 Classmates: ಠ_ಠ
@simply_the_dev7588
@simply_the_dev7588 3 жыл бұрын
Just a side not you can do this:: const res = await fetch("").then( res => res.json() ); Works the same and don't need to add another variable.
@juaninfante7000
@juaninfante7000 2 жыл бұрын
I think he does that to not get beginner confused
@istoric7221
@istoric7221 2 жыл бұрын
Thank you Ninja. getStaticProps
@rinoohhighskilled7236
@rinoohhighskilled7236 Жыл бұрын
for new ppl here with a .map() error, use it like this: (make use of props instead of ninjas) const Ninjas = (props) => { return ( All Ninjas {props.ninjas.map((ninja) => ( { ninja.name } ))} ); }
Next.js Tutorial #11 - Dynamic Routes (part 1)
5:52
Net Ninja
Рет қаралды 143 М.
Next.js Tutorial #1 - Introduction & Setup
8:43
Net Ninja
Рет қаралды 354 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Modern Data Fetching in React (Complete Guide)
16:41
Cosden Solutions
Рет қаралды 79 М.
Next.js Tutorial - 32 - SSR with getServerSideProps
9:39
Codevolution
Рет қаралды 75 М.
Next.js App Router: Routing, Data Fetching, Caching
14:32
Vercel
Рет қаралды 341 М.
Next.js Server Actions...  5 awesome things you can do
7:51
Beyond Fireship
Рет қаралды 287 М.
Client-Side VS Server-Side Rendering - Data Fetching with Next.js
13:20
freeCodeCamp Talks
Рет қаралды 184 М.
the most important Next.js features to learn (in 8 minutes)
8:26
Web Dev Cody
Рет қаралды 73 М.
Next.js Tutorial #12 - Dynamic Routes (part 2 - getStaticPaths)
6:28
Don't Make These Next.js Mistakes
13:01
Dave Gray
Рет қаралды 24 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 445 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН