Vue JS 3 Tutorial for Beginners #9 - Fetching Data

  Рет қаралды 187,567

Net Ninja

Net Ninja

Күн бұрын

Пікірлер: 150
@theebookkeeper
@theebookkeeper 2 жыл бұрын
for anyone having difficulties running the json-server command: Here is the solution: Run: npx json-server --watch data/db.json Happy coding :)
@reinoutko
@reinoutko Жыл бұрын
Thanks that worked, the line in the video gave me an error
@danielwarzecha2007
@danielwarzecha2007 Жыл бұрын
Thank you!
@razorX_09
@razorX_09 Жыл бұрын
The man's a life saver!
@programmerhp7736
@programmerhp7736 Жыл бұрын
thank you
@chip9417
@chip9417 11 ай бұрын
legend
@CV-wo9hj
@CV-wo9hj 8 ай бұрын
Awesome series thank you. With the latest json server "1.0.0-alpha.20", I had to modify db.json otherwise I kept getting a 404 not found. I had to add quotation marks around the ID numbers as follows { "jobs": [ { "id": "1", "title": "Ninja UX Designer", "details": "lorem" }, { "id": "2", "title": "Ninja Web Developer", "details": "lorem" }, { "id": "3", "title": "Ninja Vue Developer", "details": "lorem" } ] }
@nathanrochas8449
@nathanrochas8449 8 ай бұрын
Thank you I was digging the Internet searching for a fix
@AlberthAndrade
@AlberthAndrade 8 ай бұрын
Thanks bro, why does it happen? We don't know... hahaha
@mlokish
@mlokish 7 ай бұрын
Had the same issue, thanks for solution!
@who-1880
@who-1880 5 ай бұрын
thanks!
@omar2006xxx
@omar2006xxx 5 ай бұрын
Thanks! Same here.
@tswtdt555
@tswtdt555 3 жыл бұрын
Seriously, as everyone has already said, Thank you very much!! Please keep doing this!! You've helped a lot. I'm actually getting pretty good at front end development and feel confident getting into back end.
@blakebedford-palmer6676
@blakebedford-palmer6676 3 жыл бұрын
Love it! Maybe one thing overlooked, is even if you use a invalid job ID ( /jobs/6), JSON server returns 404 but sends an empty object, so when you do v-if="job" it's still true, even though this.job is just an empty object
@silenthill8312
@silenthill8312 Жыл бұрын
I gotta tell you You're a life saver Everytime i get stuck at something i always come here and miraculously almost every problem get solved
@NetNinja
@NetNinja Жыл бұрын
Aha, glad I could help :) thanks for watching!
@qhphan5
@qhphan5 3 жыл бұрын
For all those who are too lazy to navigate to the course files: { "jobs": [ { "title": "Ninja UX Designer", "id": 1, "details": "lorem" }, { "title": "Ninja Web Developer", "id": 2, "details": "lorem" }, { "title": "Ninja Vue Developer", "id": 3, "details": "lorem" } ] }
@softwareEngineerKunwar
@softwareEngineerKunwar 3 жыл бұрын
Thank for tutorials, please bring more tutorials in vue 3 like crud api, crud more. There are very few tutorials in vue 3 and you tutorials are best among them. I hope you also use bootstap 4 or 5 for ui.
@zenmasterfu
@zenmasterfu 2 жыл бұрын
If you wish to show the "results loading ..." pages add "--delay (time in ms)" to the json-server command. I use 500 ms..
@georgi_verstapen33
@georgi_verstapen33 Жыл бұрын
If you face this issue "json-server : The term 'json-server' is not recognized as the name of a cmdlet, function, script file, or operable program" Simpli write: npx json-server --watch src/data/db.json --port 3000. This will solve the above error and will host the json-server on your desired port (in this example on port 3000) Hope this helped you, dear developer :)
@黃暐倫-q4v
@黃暐倫-q4v 11 ай бұрын
Thanks, bro!
@Skaxarrat
@Skaxarrat 2 жыл бұрын
Thanks for this incredible tutorials, Shaun. btw, one way to not getting an error is making the "job" variable an object: data() { return { job: {}, } },
@dotunn
@dotunn Жыл бұрын
thanks so much, that was driving me crazy lol, i was wondering why it wasnt working
@learnsimple4592
@learnsimple4592 3 жыл бұрын
Thanks Shaun. Best tutorial ever. Just wanted to know whether you are planning on a MEVN stack or a sass tutorial and which UI com potent library do you recommend for vue.
@NetNinja
@NetNinja 3 жыл бұрын
Hey, I may do a full stack Vue project at some point but was thinking of using GraphQL. May also do a SASS refresh at some point too. I really like Vuetify for Vue 2, looking forward to it's new relase for v3 :)
@learnsimple4592
@learnsimple4592 3 жыл бұрын
@@NetNinja As long as it is Vue fullstack (graphQL or MEVN). Count me in.
@hassanmiiro1030
@hassanmiiro1030 3 жыл бұрын
@@learnsimple4592 @The Net Ninja me too.
@00el04
@00el04 3 жыл бұрын
@@NetNinja subscribed for more future content :)
@mateuszfrydrych9822
@mateuszfrydrych9822 2 жыл бұрын
A little hint: for chromium-based browsers (Chrome, Edge, I don't know about others) you can limit the network speed for the browser. This is done in the "Network" tab (where you have viewed the queries sent to the server) from the "Unlimited" option to one of the ready settings, eg "Fast 3G network" or "Slow 3G network" or any custom setting. Regards
@kajganamakedonska1846
@kajganamakedonska1846 Жыл бұрын
why would you do that?
@bakatoroi
@bakatoroi Жыл бұрын
@@kajganamakedonska1846 To better see what happens at 11:30. Also testing in general.
@mauricemakesmovies
@mauricemakesmovies Жыл бұрын
You're a great teacher. Keep up the good work Shaun!
@NetNinja
@NetNinja Жыл бұрын
Thanks Maurice, I appreciate that! :)
@angelosarnaoutis6391
@angelosarnaoutis6391 3 жыл бұрын
If you want to test "loading jobs...", you can add a delay to the response of the json server. This can be done by adding to the json-server command the --delay or -d and the the number of milliseconds you want the response to be delayed.
@franklinsampaio9254
@franklinsampaio9254 3 жыл бұрын
Or you can just press F12, go to network and change from 'online' to 'slow 3g'. With that you can test this too...
@deletedaccount-b5o
@deletedaccount-b5o 2 жыл бұрын
You are a brilliant teacher! Thank you very much!
@dayanavm
@dayanavm 3 жыл бұрын
npx json-server --watch data/db.json = This command help me to watch file using json-server in windows.
@nasserwaleed-y8u
@nasserwaleed-y8u 8 ай бұрын
doesn't work, that appear in my screen ; file:///C:/Users/aa/AppData/Roaming/npm/node_modules/json-server/lib/bin.js:4 import { parseArgs } from 'node:util'; ^^^^^^^^^ SyntaxError: The requested module 'node:util' does not provide an export named 'parseArgs' at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21) at async ModuleJob.run (node:internal/modules/esm/module_job:194:5) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:385:24) at async loadESM (node:internal/process/esm_loader:88:5) at async handleMainPromise (node:internal/modules/run_main:61:12)
@marcmil4064
@marcmil4064 7 ай бұрын
Awesome video! One suggestion though: We should hope that the company always has at least one open job, otherwise the length of the array will stay 0 and "Loading" will be shown forever ;)
@lilmila4533
@lilmila4533 2 жыл бұрын
is there a tutorial of yours which you use database instead of a json?
@kaleabwoldemariam4288
@kaleabwoldemariam4288 4 ай бұрын
Thank you for the thorough tutorial.❤
@NetNinja
@NetNinja 4 ай бұрын
Hope it was helpful! thanks for watching :)
@danielorkan5151
@danielorkan5151 3 жыл бұрын
$ json-server -watch data/db.json (I got command not found: json-server) I'm using MacOS with npm (6.14.4) In order to solve this I had to uninstall json-server using: $ npm uninstall json-server and then install json-server globally using: $ npm install -g json-server
@bytesoclock
@bytesoclock 3 жыл бұрын
thank you
@danielwarzecha2007
@danielwarzecha2007 Жыл бұрын
Note: at the 12 minute mark, if your getting a net::ERR_BLOCKED_BY_CLIENT error message....it is likely that it is your browser ad blocker! disable it, or use a different browser, this was the problem for me when using the brave browser, I just clicked the lion head and disabled it and it works fine
@Akosiyawin
@Akosiyawin 2 жыл бұрын
Hi, from my experience you would fetch data in a created() life cycle hook, it's much better for handling get requests
@robinbeaudru6892
@robinbeaudru6892 2 жыл бұрын
Thank you, very useful tutorial series. I'm wondering, why don't you have to filter the results from the fetch with the id props? is JSON Server already configured for that? Cheers!
@hawarhekmat1174
@hawarhekmat1174 3 жыл бұрын
thank you, you are teaching in best way ❤️
@BarbaraBezd
@BarbaraBezd 6 ай бұрын
Thank you very much for your course! it's extremely helpful and easy to understand!
@NetNinja
@NetNinja 6 ай бұрын
Glad it was helpful! :) thanks for watching
@gilbertandsausage
@gilbertandsausage Жыл бұрын
After installing json-server it wouldn't let me use json-server in command line, to fix this I installed it globally adding the -g tag after "install" then installing it locally to the project. I'm not sure if anyone else has experienced this issue but if you are this is how you resolve that.
@badreddinlabed530
@badreddinlabed530 3 жыл бұрын
Thank u so much Ninja ❤ u are the best!
@Новаинжиниринг
@Новаинжиниринг 2 жыл бұрын
Such an excellent video! Thank you!
@NetNinja
@NetNinja 2 жыл бұрын
You're very welcome!
@3d_cube_3d95
@3d_cube_3d95 2 жыл бұрын
How do I cancel my previous fetch request ? Let's say I was fetching a data on my project then while my page is still fetching I changed to another page route?
@chenqu773
@chenqu773 3 жыл бұрын
I doun't knaow the origin of your accent. Bot it's very charming I reeely like it!
@NetNinja
@NetNinja 3 жыл бұрын
Thank you! 😃 I'm from Manchester, UK!
@chenqu773
@chenqu773 3 жыл бұрын
@@NetNinja Hoooray! Again, many thanks to your great tutorial !
@derekbressler9154
@derekbressler9154 3 жыл бұрын
vue is the best!
@hassaniqbal6199
@hassaniqbal6199 3 жыл бұрын
agree
@derekbressler9154
@derekbressler9154 3 жыл бұрын
agree
@sauravjain6135
@sauravjain6135 3 жыл бұрын
Noobs favourite: Angular Pro favourite: React Hackers favourite: Vue
@BenjaminGSlade
@BenjaminGSlade 7 ай бұрын
"fetch data", does that mean fetch data from a database to memory? or to/from/ memory from/to the screen?
@ankithap7624
@ankithap7624 3 жыл бұрын
thank you for your awesome content shaun
@jimos9878
@jimos9878 11 ай бұрын
The same way 'jobs' is not null because it's just an empty array (value), couldn't we set 'job' property to {} instead of null? So it would be an empty object and not null. Or is {} still a null value?
@tomvanbrabant3053
@tomvanbrabant3053 3 жыл бұрын
Why not pass the job as a prop to JobDetails? For production, would it be better performance because you don't fetch it twice? Thanks.
@ИгорьИванов-т1ю
@ИгорьИванов-т1ю 2 жыл бұрын
I undestand how make a list of items in json-server, but how to delete any item from my list using fetch request? how to address to exact id?
@khouloudcherrat1060
@khouloudcherrat1060 2 жыл бұрын
at 15:58 the problem can be fixed quickly if we set job : {}.
@MatichekYoutube
@MatichekYoutube 2 жыл бұрын
Hi, can you create multiple fetch statements there?
@ghostkillerbr9
@ghostkillerbr9 Жыл бұрын
thankss :)
@chanhkunbin906
@chanhkunbin906 2 жыл бұрын
i using axios and call api from MongoDB, however when i get the id from the job page it says detailJobs error 404 has format detailJobs/undefined
@dikebambangsk4864
@dikebambangsk4864 2 жыл бұрын
is it fetch automatic can call after install on package.json, not import the node-fetch
@jamols09
@jamols09 3 жыл бұрын
I just think its better to cover on axios than fetch
@anthonygoodjobs4544
@anthonygoodjobs4544 3 жыл бұрын
Not really, it's much better to use the native Fetch for these type of cases.
@0jhivag
@0jhivag Жыл бұрын
Great,but how i do this in composition api,how i get the id?
@pt_trainer9244
@pt_trainer9244 Жыл бұрын
Use props or vue router and pass the Id with the params parameter
@tona17yo
@tona17yo 2 жыл бұрын
Pero de esta forma haces 2 peticiones, en la primera ya tienes todo, por qué no almacenarlo en vuex y desplegar la data necesaria por medio de su id?
@lilmila4533
@lilmila4533 2 жыл бұрын
how can we fetch data from a created database server for vue.js?
@rommyrisyandi2863
@rommyrisyandi2863 2 жыл бұрын
i got problem in section 5:26 and the problem is this : json-server : The term 'json-server' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 is there anyone can help me?
@ccindy951357
@ccindy951357 9 ай бұрын
謝謝!
@不滅のキュレル
@不滅のキュレル 3 жыл бұрын
Thank you ! by japanese(日本人)
@g2rocky231
@g2rocky231 3 жыл бұрын
Hello sir, I want to learn app development. But I don't know which one to prefer "react-native" or "flutter". I know react js very well and also flutter a bit. Can you prefer which one is better.
@kajganamakedonska1846
@kajganamakedonska1846 Жыл бұрын
if you know whats there to learn>?
@ridl27
@ridl27 3 жыл бұрын
ty.
@SUBZER0GREEN
@SUBZER0GREEN Жыл бұрын
9:00
@antoniofuller2331
@antoniofuller2331 2 жыл бұрын
Hmmm
@shubhang2877
@shubhang2877 3 жыл бұрын
What is your dog's name?
@NetNinja
@NetNinja 3 жыл бұрын
I don't have one, but if I did I would call it Yoshi :)
@shubhang2877
@shubhang2877 3 жыл бұрын
Wait then who's the cutie on your github pfp?
@ivansanczewski6648
@ivansanczewski6648 Жыл бұрын
I bought this tutorial and follow this part and it worked fine for me, until I had to use a json file with Pinia… I can GET mock data from my file and populate an array, but when it comes to POST new data I keep on receiving this error: "POST localhost:3000/borrowedBooks 500 (Internal Server Error)" Any help would be highly appreciated!
@_isaac_muniz_
@_isaac_muniz_ 2 жыл бұрын
i wasn't able to run json-server so i installed it globally with 'npm install -g json-server' and it worked fine
@jesserigon
@jesserigon Жыл бұрын
why use mounted hook and not beforemount or something like that so you dont have to write all the conditionals?
@alielzahaby3315
@alielzahaby3315 10 ай бұрын
{ "jobs": [ { "title": "Ninja UX Designer", "id": 1, "details": "lorem" }, { "title": "Ninja Web Developer", "id": 2, "details": "lorem" }, { "title": "Ninja Vue Developer", "id": 3, "details": "lorem" } ] } np ;)
@RohitThakur-sj7en
@RohitThakur-sj7en 3 жыл бұрын
I stopped continuing Vue and switched to React a few months ago. But, now I'm back, thanks to you. Love your tutorials :)
@mohdmahtab8991
@mohdmahtab8991 3 жыл бұрын
React vs Vue which one best ?
@RohitThakur-sj7en
@RohitThakur-sj7en 3 жыл бұрын
@@mohdmahtab8991 Both of them are great frameworks. But I would suggest going with Vue as it is a lot more beginner friendly.
@TheCodingOdyssey
@TheCodingOdyssey 3 жыл бұрын
I've been working with React for over a year. I am thinking to start learning Vue as well. How different is it?
@mohdmahtab8991
@mohdmahtab8991 3 жыл бұрын
@@RohitThakur-sj7en thankyou brother 🙂
@RohitThakur-sj7en
@RohitThakur-sj7en 3 жыл бұрын
@@TheCodingOdyssey I would insist you to give it a try. Everything is far more convenient in Vue.
@tomvanbrabant3053
@tomvanbrabant3053 3 жыл бұрын
Many thanks for these great tutorials!
@yadude101
@yadude101 3 жыл бұрын
at 4:00 , aren't yarn🧶installs better for Macs? with npm, a lot of the time you have to do a sudo install, which isn't advisable
@rickycaron2177
@rickycaron2177 3 жыл бұрын
Hello, I have a question. What if I want to use "job title" to search in the JSON array by the fetch function, rather than using "id"? Is there a way to do so?
@emil371
@emil371 2 жыл бұрын
Did you find a way to do this?
@Viralplace
@Viralplace Жыл бұрын
Finally you don't explain the lazy-loading route... what is the difference
@00el04
@00el04 3 жыл бұрын
so would you rarely fetch JSON data on a local file server?
@Ln6Ec
@Ln6Ec 7 ай бұрын
The mounted fetch request within JobDetails isn't working for me for some reason... if I have the (res => res.json()) portion in it, there's an unexpected character error that comes up. If I switch res.json() to res.text() that error goes away, but I get another error saying the requested localhost:3000/jobs/1 isn't found. Can anyone help me please?
@miloszl0
@miloszl0 6 ай бұрын
add quotation marks to the ID in json file, like this: { "jobs": [ { "id": "1", "title": "Ninja UX Designer", "details": "lorem" }, { "id": "2", "title": "Ninja Web Developer", "details": "lorem" }, { "id": "3", "title": "Ninja Vue Developer", "details": "lorem" } ] }
@creadigma360
@creadigma360 2 жыл бұрын
Very helpful. I have fetched users with '/wp/v2/users' endpoint, but I can only get my own user data, I get a 401 error response when trying to get something like '/wp/v2/users/2'. How can I authenticate in order to get All Users data? I need to lists employees... I tried adding a header argument to the fetch function but it didn't work, I'm guessing It's because headers had already been sent, but I'm new to WP API REST, and to Vuejs, so I don't really know... I'm simply adding Vuejs for a couple of pages, as a script file from a CDN. I only find information about classic ajax so I don't know how to authenticate through API REST and Vuejs P.D. : I had already generated my application password, just don't know where/how to place credentials. Running WP 5.9.3
@trickytricks3071
@trickytricks3071 3 жыл бұрын
how to get data from list without using loop? I am import array of data from api but i want to you use only one row,so please tell me how to get data using index number... I have tried list[0].title but it shows error
@fredpourlesintimes
@fredpourlesintimes 2 жыл бұрын
Interesting and proper way to work with data. Thanks :)
@mustafaerk3491
@mustafaerk3491 3 жыл бұрын
If we got error UI will present still loading bc we didnt change jobs.length or job if we got error but btw it was great tutorial. Its not hard to handle that case . Thank you
@michalsejak
@michalsejak 2 жыл бұрын
Why does this not cause the CORS policy problem? Can anyone please explain that to me?
@diamondsky6605
@diamondsky6605 3 жыл бұрын
I love your voice you're good for explaining the code Shout-out from France ❤️
@sudhanwabokade1285
@sudhanwabokade1285 3 ай бұрын
11:00
@ramohacks
@ramohacks 3 жыл бұрын
Is it a preference to using mounted vs created vs beforeMounted ?
@yusha790
@yusha790 2 жыл бұрын
keep making vue vids please
@bryannsi
@bryannsi 3 жыл бұрын
how setup vue auto-complete in vscode?
@adilizm704
@adilizm704 3 жыл бұрын
i can't get the data when I pass the id as a parameter to the API how you did that ?? I think you miss a part there ?? any idea
@yasthatsme
@yasthatsme 3 жыл бұрын
Watch 14:00
@derekbressler9154
@derekbressler9154 3 жыл бұрын
vue is the best
@yaqubyusuf2834
@yaqubyusuf2834 3 жыл бұрын
Thank you
@rezwansaki
@rezwansaki 3 жыл бұрын
Thanks :)
@paycation3966
@paycation3966 3 жыл бұрын
Is this tutor British?
@NetNinja
@NetNinja 3 жыл бұрын
Hey yes, I am from Manchester, England :)
@dlysele
@dlysele 3 жыл бұрын
Hi there, I am just learning Vue and I am creating a map app. I have already placed a geolocation script to output the latitude and longitude values on the DOM but I don't know how to refer the data back to the server, do you have an clue what I should do/look for? Thank you!
@gokulpisharody3155
@gokulpisharody3155 3 жыл бұрын
Shaun what about angular course? Any plan to create one.?
Вся суть работы с внешним API на Vue | Просто объясняю Vue 3
15:24
Lectoria. Обучение веб-разработке.
Рет қаралды 17 М.
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 69 МЛН
The day of the sea 😂 #shorts by Leisi Crazy
00:22
Leisi Crazy
Рет қаралды 1,7 МЛН
How To Get Married:   #short
00:22
Jin and Hattie
Рет қаралды 20 МЛН
Vue JS 3 Tutorial for Beginners #8 - The Vue Router
47:48
Net Ninja
Рет қаралды 267 М.
Fetching Data in React - Complete Tutorial
29:10
Cosden Solutions
Рет қаралды 124 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
5 Ways to Fetch Data from an API in Vue 3 Composition API
6:28
Justin Brooks
Рет қаралды 73 М.
I built the same app 10 times // Which JS Framework is best?
21:58
Fireship
Рет қаралды 2,5 МЛН
Vue 3 Composition API Introduction [FULL TUTORIAL]
23:46
Academind
Рет қаралды 175 М.
Learn Fetch API In 6 Minutes
6:35
Web Dev Simplified
Рет қаралды 1,2 МЛН
Vue JS #2 - Use Axios to get data and resolve CORS issue
9:11
Code with Bibek
Рет қаралды 39 М.
Axios Crash Course | HTTP Library
42:20
Traversy Media
Рет қаралды 369 М.
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 69 МЛН