5 Ways to Fetch Data from an API in Vue 3 Composition API

  Рет қаралды 71,577

Justin Brooks

Justin Brooks

Күн бұрын

There are many ways to extract data in Vue, so today, we'll look at 5 ways you can fetch data in your application. We will also look at the new Vue 3 suspense API which tackles this problem differently and create our own composable function to maximize reusability.
✨ SOCIAL ✨
Discord - / discord
Twitter - / jsbroks
⚡ RESOURCES ⚡
Vue 3 Suspense - vueschool.io/articles/vuejs-t...
⭐ TIMESTAMPS ⭐
0:00 - Vue Data Fetching
0:28 - Where to fetch data
1:09 - Fetch API
1:33 - Axios
2:15 - async/await onMounted
2:34 - Async Component
3:19 - Composable Functions
3:56 - Custom fetch hook
4:38 - Fetch hook with Cache
#Vue #Fetching #Data

Пікірлер: 45
@Ma1ne2
@Ma1ne2 3 жыл бұрын
Great explanation with great visuals, a calming voice to listen to and exciting but understating music, I loved it! Got a new sub m8 ☺️
@parogparog6774
@parogparog6774 2 жыл бұрын
Very concise and to the point. I don't subscribe to channels very often, but the format and depth for the different possibilities you bring up are exactly the type of content an experience dev is looking for. :) Thanks!
@MrBiggydicks
@MrBiggydicks 3 жыл бұрын
Nice one. I'm actually in my first Vue 3 production project right now. I don't actually need any API calls for this one but still good to know
@ferhatsunaycansev106
@ferhatsunaycansev106 2 жыл бұрын
useFetch example is very very very great thanks alot man! love from Turkey!
@_the_one_1
@_the_one_1 3 жыл бұрын
Great video as always Justin. Please create a Vue 3 course and take my money!
@2603bex
@2603bex 2 жыл бұрын
Brilliant! Thank you
@jntaca
@jntaca 3 жыл бұрын
Thanks ! Very useful .
@darkmift
@darkmift 3 жыл бұрын
Its always good practice to add a repo or gist link to the code used in the presentation. Great demo,first time I see use of cache logic and the map use is very cool.
@paws7983
@paws7983 2 жыл бұрын
Many thanks to Justin!
@RianY2K
@RianY2K 3 жыл бұрын
thanks for tutorial. Vue JS 3 looks good in Syntax and API
@CodingWithJustin
@CodingWithJustin 3 жыл бұрын
It does!
@Mahmudulhasan-ts5hm
@Mahmudulhasan-ts5hm 17 күн бұрын
nice, love vue.js
@gagiknavasatariyan7316
@gagiknavasatariyan7316 3 жыл бұрын
Hi, Great content Thanks!
@zekariyasmulugetaaltaye1065
@zekariyasmulugetaaltaye1065 2 жыл бұрын
this video just saved my ass from a lot of trouble, Literally. Thank you
@sivasankarant9195
@sivasankarant9195 3 жыл бұрын
Justin thanks man
@RSurya99
@RSurya99 2 жыл бұрын
can you explain how to use the method created in last section? because when I call it on component it will return Computedrefimpl
@LukeryaPereprygova
@LukeryaPereprygova 3 жыл бұрын
Very fireship-y))
@Endersontutoriales
@Endersontutoriales 3 жыл бұрын
Nice!!
@marvin_e
@marvin_e 3 жыл бұрын
damn.. this is so awesome
@AnisD756
@AnisD756 Жыл бұрын
It's probably overkill for just a basic fetch but that last function is really cool. I had to pause screen to copy it :p
@carlosalvarado5331
@carlosalvarado5331 3 жыл бұрын
I was trying the sample code that you provide the get method is OK but how can I create a post request :v
@kinax2
@kinax2 3 жыл бұрын
Can you make a vue-i18n@next with routing video ?
@epiiiiiii
@epiiiiiii 3 жыл бұрын
Good stuff. I just wish you were using the Options API until I catch up. 😜
@ColinRichardson
@ColinRichardson Жыл бұрын
I didn't think you could use 'reactive' outside of the 'use' function because it had the potential to be initialised before the Vue instance had been configured?
@junaidjahan6864
@junaidjahan6864 Жыл бұрын
Awesome
@AhSoh7091
@AhSoh7091 3 жыл бұрын
Thanks for sharing, do you have real example to use the useFetchCache hook? i tried it doesn't really work correctly. Hope you can share more about it.
@CodingWithJustin
@CodingWithJustin 3 жыл бұрын
It depends on you are using the hook. If you call the two hook immediate after each with the same key, both fetches will be called, since there is nothing in cache until a fetch has finished. This makes it useful for grabing information in lower components that are only dispalyed if a apprent component fetch has successed, or when coming back to the same page as mentioned in the video. Of course you can expand on the hook to make it better.
@AhSoh7091
@AhSoh7091 3 жыл бұрын
@@CodingWithJustin​Thanks for your explanation. Anyway, you made a ton of great video. i love to watch your video.
@pierre1360
@pierre1360 2 жыл бұрын
what is that ref() stuff?
@emonymph6911
@emonymph6911 2 жыл бұрын
Should have made video longer and shown examples of how it works by grabbing X from front end and storing it in DB at backend so we can visualize each method and select what we prefer syntaxically. You should also mention which fetching methods are compatible with web components and which are not, make a table (consider it as feedback)
@lilmila4533
@lilmila4533 Жыл бұрын
YES! Is there a tutorial like this you know? I could not find it :(
@DK-pf2dg
@DK-pf2dg 3 жыл бұрын
Please make guide how to create a pagination.
@ricko13
@ricko13 2 жыл бұрын
gold
@fifty6737
@fifty6737 2 жыл бұрын
the composition api is miles ahead of react hooks, they really nailed it with this types and functions
@Nexus9997
@Nexus9997 Жыл бұрын
I honestly prefer Vue but i've never really used the composition api, so what makes you think that ?
@zlatkoiliev8927
@zlatkoiliev8927 5 ай бұрын
Shouldn’t we invalidate the cache after some time?!? The approach from the example absolutely prevent fetching new data if we already have cached key. Maybe it will be a good idea to only keep the cache for some time like 15 min or something…
@Orphy7
@Orphy7 2 жыл бұрын
I m watching a lot of these video but I still can’t understand how should I do to connect vue and axios with my msql database :(
@AnisD756
@AnisD756 Жыл бұрын
You can use something like Api-platform
@ranavitaln
@ranavitaln Жыл бұрын
Please show examples 🙏
@rafaelgramoschi957
@rafaelgramoschi957 11 ай бұрын
when you check "!config.skip && fetch()" you must "!config.skip && AWAIT fetch()"
@LeLeTesoro
@LeLeTesoro 2 жыл бұрын
This video is like, "Info for beginners, beginners, beginners, dissertation for 2nd PhD in computer science, The End"
@MarcdeRuyter
@MarcdeRuyter 2 жыл бұрын
This only confuses matters
@MrNihilius
@MrNihilius 2 жыл бұрын
please without music
@Markus-iq4sm
@Markus-iq4sm Жыл бұрын
Awful explanation, for useFetch you just copy-pace useAsyncState source code function from VueUse. What did you explaine? The case when author does not understand what he actually says
@jaromanda
@jaromanda 2 жыл бұрын
you lost me at axios - it has "a much shorter syntax" ... sure, it does, it's a JS library written using the old XMLHttpRequest methods It's SO easy to write a very small library, using fetch, that exposes a similar, short, syntax Seriously, you create a function called `useFetch` ... which uses axios (which uses native XMLHttpRequest, not native Fetch) --- sacrilege!!! You probably use internet explorer 7 as your daily web browser!!!
Vue 3: Reactivity Made Easy (ref, reactive, toRefs... oh my!)
13:04
Program With Erik
Рет қаралды 48 М.
Despicable Me Fart Blaster
00:51
_vector_
Рет қаралды 25 МЛН
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 9 МЛН
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 11 МЛН
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 105 М.
15 Vue 3 Tips and Tricks
6:36
Justin Brooks
Рет қаралды 33 М.
Build your own Custom Composables in Vue
12:13
Vue Mastery
Рет қаралды 40 М.
7 Important Vue 3 Composition and Composable Functions Explained
6:25
Vue explained to React Developers in 6 mins
6:33
Justin Brooks
Рет қаралды 40 М.
A Better Way To Organize Components In Vue
10:10
Program With Erik
Рет қаралды 18 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 774 М.
Learn Pinia in 30 MINUTES! (Vue JS 3)
33:58
Make Apps with Danny
Рет қаралды 116 М.
Organize your Composition API code (2k subscriber special)
18:22
Alexander Lichter
Рет қаралды 21 М.
تجربة أغرب توصيلة شحن ضد القطع تماما
0:56
صدام العزي
Рет қаралды 59 МЛН
Looks very comfortable. #leddisplay #ledscreen #ledwall #eagerled
0:19
LED Screen Factory-EagerLED
Рет қаралды 1,7 МЛН
iPhone, Galaxy или Pixel? 😎
0:16
serg1us
Рет қаралды 1,1 МЛН
Samsung laughing on iPhone #techbyakram
0:12
Tech by Akram
Рет қаралды 2,1 МЛН
Это - iPhone 16 и вот что надо знать...
17:20
Overtake lab
Рет қаралды 119 М.