Vue JS 3 Tutorial for Beginners #9 - Fetching Data

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ธ.ค. 2024

ความคิดเห็น • 150

  • @theebookkeeper
    @theebookkeeper 2 ปีที่แล้ว +96

    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 2 ปีที่แล้ว +2

      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 ปีที่แล้ว

      legend

  • @CV-wo9hj
    @CV-wo9hj 10 หลายเดือนก่อน +23

    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 10 หลายเดือนก่อน

      Thank you I was digging the Internet searching for a fix

    • @AlberthAndrade
      @AlberthAndrade 10 หลายเดือนก่อน

      Thanks bro, why does it happen? We don't know... hahaha

    • @mlokish
      @mlokish 9 หลายเดือนก่อน

      Had the same issue, thanks for solution!

    • @who-1880
      @who-1880 8 หลายเดือนก่อน

      thanks!

    • @omar2006xxx
      @omar2006xxx 7 หลายเดือนก่อน

      Thanks! Same here.

  • @blakebedford-palmer6676
    @blakebedford-palmer6676 3 ปีที่แล้ว +6

    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

  • @tswtdt555
    @tswtdt555 3 ปีที่แล้ว +20

    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.

  • @silenthill8312
    @silenthill8312 ปีที่แล้ว +2

    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!

  • @RohitThakur-sj7en
    @RohitThakur-sj7en 4 ปีที่แล้ว +17

    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 4 ปีที่แล้ว +1

      React vs Vue which one best ?

    • @RohitThakur-sj7en
      @RohitThakur-sj7en 4 ปีที่แล้ว +10

      @@mohdmahtab8991 Both of them are great frameworks. But I would suggest going with Vue as it is a lot more beginner friendly.

    • @TheCodingOdyssey
      @TheCodingOdyssey 4 ปีที่แล้ว +6

      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 4 ปีที่แล้ว +2

      @@RohitThakur-sj7en thankyou brother 🙂

    • @RohitThakur-sj7en
      @RohitThakur-sj7en 4 ปีที่แล้ว +6

      @@TheCodingOdyssey I would insist you to give it a try. Everything is far more convenient in Vue.

  • @qhphan5
    @qhphan5 3 ปีที่แล้ว +7

    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" }
    ]
    }

  • @learnsimple4592
    @learnsimple4592 4 ปีที่แล้ว +10

    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  4 ปีที่แล้ว +8

      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 4 ปีที่แล้ว

      @@NetNinja As long as it is Vue fullstack (graphQL or MEVN). Count me in.

    • @hmiiro
      @hmiiro 4 ปีที่แล้ว

      @@learnsimple4592 @The Net Ninja me too.

    • @00el04
      @00el04 3 ปีที่แล้ว +1

      @@NetNinja subscribed for more future content :)

  • @mauricemakesmovies
    @mauricemakesmovies 2 ปีที่แล้ว +2

    You're a great teacher. Keep up the good work Shaun!

    • @NetNinja
      @NetNinja  2 ปีที่แล้ว +2

      Thanks Maurice, I appreciate that! :)

  • @softwareEngineerKunwar
    @softwareEngineerKunwar 3 ปีที่แล้ว +5

    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.

  • @_isaac_muniz_
    @_isaac_muniz_ 2 ปีที่แล้ว +2

    i wasn't able to run json-server so i installed it globally with 'npm install -g json-server' and it worked fine

  • @zenmasterfu
    @zenmasterfu 2 ปีที่แล้ว +4

    If you wish to show the "results loading ..." pages add "--delay (time in ms)" to the json-server command. I use 500 ms..

  • @mateuszfrydrych9822
    @mateuszfrydrych9822 2 ปีที่แล้ว +4

    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 ปีที่แล้ว +1

      why would you do that?

    • @bakatoroi
      @bakatoroi ปีที่แล้ว +2

      @@kajganamakedonska1846 To better see what happens at 11:30. Also testing in general.

  • @georgi_verstapen33
    @georgi_verstapen33 ปีที่แล้ว +2

    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 :)

  • @ohmydefense
    @ohmydefense 2 ปีที่แล้ว +1

    You are a brilliant teacher! Thank you very much!

  • @Skaxarrat
    @Skaxarrat 3 ปีที่แล้ว +5

    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 ปีที่แล้ว +1

      thanks so much, that was driving me crazy lol, i was wondering why it wasnt working

  • @robinbeaudru6892
    @robinbeaudru6892 2 ปีที่แล้ว +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!

  • @tomvanbrabant3053
    @tomvanbrabant3053 3 ปีที่แล้ว +2

    Many thanks for these great tutorials!

  • @lilmila4533
    @lilmila4533 2 ปีที่แล้ว +3

    is there a tutorial of yours which you use database instead of a json?

  • @ccindy951357
    @ccindy951357 11 หลายเดือนก่อน

    謝謝!

  • @dayanavm
    @dayanavm 3 ปีที่แล้ว +3

    npx json-server --watch data/db.json = This command help me to watch file using json-server in windows.

    • @nasserwaleed-y8u
      @nasserwaleed-y8u 10 หลายเดือนก่อน

      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)

  • @BarbaraBezd
    @BarbaraBezd 8 หลายเดือนก่อน

    Thank you very much for your course! it's extremely helpful and easy to understand!

    • @NetNinja
      @NetNinja  8 หลายเดือนก่อน

      Glad it was helpful! :) thanks for watching

  • @Viralplace
    @Viralplace 2 ปีที่แล้ว

    Finally you don't explain the lazy-loading route... what is the difference

  • @hawarhekmat1174
    @hawarhekmat1174 4 ปีที่แล้ว +1

    thank you, you are teaching in best way ❤️

  • @marcmil4064
    @marcmil4064 10 หลายเดือนก่อน

    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 ;)

  • @diamondsky6605
    @diamondsky6605 3 ปีที่แล้ว

    I love your voice you're good for explaining the code
    Shout-out from France ❤️

  • @angelosarnaoutis6391
    @angelosarnaoutis6391 3 ปีที่แล้ว +8

    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.

    • @franklinpsampaio
      @franklinpsampaio 3 ปีที่แล้ว +4

      Or you can just press F12, go to network and change from 'online' to 'slow 3g'. With that you can test this too...

  • @kaleabwoldemariam4288
    @kaleabwoldemariam4288 6 หลายเดือนก่อน

    Thank you for the thorough tutorial.❤

    • @NetNinja
      @NetNinja  6 หลายเดือนก่อน

      Hope it was helpful! thanks for watching :)

  • @yadude101
    @yadude101 3 ปีที่แล้ว +1

    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

  • @fredpourlesintimes
    @fredpourlesintimes 2 ปีที่แล้ว

    Interesting and proper way to work with data.
    Thanks :)

  • @badreddinlabed530
    @badreddinlabed530 4 ปีที่แล้ว +1

    Thank u so much Ninja ❤ u are the best!

  • @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

  • @gilbertandsausage
    @gilbertandsausage 2 ปีที่แล้ว +4

    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.

  • @Новаинжиниринг
    @Новаинжиниринг 2 ปีที่แล้ว +1

    Such an excellent video! Thank you!

    • @NetNinja
      @NetNinja  2 ปีที่แล้ว

      You're very welcome!

  • @alielzahaby3315
    @alielzahaby3315 ปีที่แล้ว +1

    {
    "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 ;)

  • @sauravjain6135
    @sauravjain6135 4 ปีที่แล้ว +5

    Noobs favourite: Angular
    Pro favourite: React
    Hackers favourite: Vue

  • @00el04
    @00el04 3 ปีที่แล้ว +1

    so would you rarely fetch JSON data on a local file server?

  • @ramohacks
    @ramohacks 3 ปีที่แล้ว

    Is it a preference to using mounted vs created vs beforeMounted ?

  • @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

  • @jesserigon
    @jesserigon ปีที่แล้ว +1

    why use mounted hook and not beforemount or something like that so you dont have to write all the conditionals?

  • @khouloudcherrat1060
    @khouloudcherrat1060 2 ปีที่แล้ว +1

    at 15:58 the problem can be fixed quickly if we set job : {}.

  • @ankithap7624
    @ankithap7624 3 ปีที่แล้ว

    thank you for your awesome content shaun

  • @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

  • @danielorkan5151
    @danielorkan5151 3 ปีที่แล้ว +4

    $ 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

  • @chenqu773
    @chenqu773 3 ปีที่แล้ว +1

    I doun't knaow the origin of your accent. Bot it's very charming I reeely like it!

    • @NetNinja
      @NetNinja  3 ปีที่แล้ว +1

      Thank you! 😃 I'm from Manchester, UK!

    • @chenqu773
      @chenqu773 3 ปีที่แล้ว +1

      @@NetNinja Hoooray! Again, many thanks to your great tutorial !

  • @derekbressler9154
    @derekbressler9154 4 ปีที่แล้ว +2

    vue is the best!

  • @rickycaron2177
    @rickycaron2177 3 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      Did you find a way to do this?

  • @MatichekYoutube
    @MatichekYoutube 3 ปีที่แล้ว

    Hi, can you create multiple fetch statements there?

  • @3d_cube_3d95
    @3d_cube_3d95 3 ปีที่แล้ว +1

    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?

  • @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.

  • @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?

  • @jamols09
    @jamols09 3 ปีที่แล้ว +1

    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

  • @ghostkillerbr9
    @ghostkillerbr9 ปีที่แล้ว +1

    thankss :)

  • @不滅のキュレル
    @不滅のキュレル 3 ปีที่แล้ว

    Thank you ! by japanese(日本人)

  • @jimos9878
    @jimos9878 ปีที่แล้ว

    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?

  • @yusha790
    @yusha790 2 ปีที่แล้ว

    keep making vue vids please

  • @tona17yo
    @tona17yo 3 ปีที่แล้ว

    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?

  • @ИгорьИванов-т1ю
    @ИгорьИванов-т1ю 3 ปีที่แล้ว

    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?

  • @yaqubyusuf2834
    @yaqubyusuf2834 3 ปีที่แล้ว

    Thank you

  • @derekbressler9154
    @derekbressler9154 4 ปีที่แล้ว

    vue is the best

  • @BenjaminGSlade
    @BenjaminGSlade 9 หลายเดือนก่อน

    "fetch data", does that mean fetch data from a database to memory? or to/from/ memory from/to the screen?

  • @dikebambangsk4864
    @dikebambangsk4864 2 ปีที่แล้ว

    is it fetch automatic can call after install on package.json, not import the node-fetch

  • @lilmila4533
    @lilmila4533 2 ปีที่แล้ว

    how can we fetch data from a created database server for vue.js?

  • @bryannsi
    @bryannsi 3 ปีที่แล้ว

    how setup vue auto-complete in vscode?

  • @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

  • @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

  • @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

  • @g2rocky231
    @g2rocky231 4 ปีที่แล้ว +1

    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.

  • @ridl27
    @ridl27 4 ปีที่แล้ว

    ty.

  • @dlysele
    @dlysele 3 ปีที่แล้ว +1

    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!

  • @rezwansaki
    @rezwansaki 3 ปีที่แล้ว

    Thanks :)

  • @michalsejak
    @michalsejak 3 ปีที่แล้ว

    Why does this not cause the CORS policy problem? Can anyone please explain that to me?

  • @gokulpisharody3155
    @gokulpisharody3155 4 ปีที่แล้ว

    Shaun what about angular course? Any plan to create one.?

  • @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

  • @Ln6Ec
    @Ln6Ec 9 หลายเดือนก่อน

    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 8 หลายเดือนก่อน

      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"
      }
      ]
      }

  • @sudhanwabokade1285
    @sudhanwabokade1285 5 หลายเดือนก่อน

    11:00

  • @shubhang2877
    @shubhang2877 4 ปีที่แล้ว

    What is your dog's name?

    • @NetNinja
      @NetNinja  4 ปีที่แล้ว +4

      I don't have one, but if I did I would call it Yoshi :)

    • @shubhang2877
      @shubhang2877 4 ปีที่แล้ว +2

      Wait then who's the cutie on your github pfp?

  • @SUBZER0GREEN
    @SUBZER0GREEN ปีที่แล้ว

    9:00

  • @antoniofuller2331
    @antoniofuller2331 3 ปีที่แล้ว

    Hmmm

  • @paycation3966
    @paycation3966 3 ปีที่แล้ว

    Is this tutor British?

    • @NetNinja
      @NetNinja  3 ปีที่แล้ว +2

      Hey yes, I am from Manchester, England :)

  • @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!