3.1 API calls from Node.js (Weather data from Dark Sky) - Working with Data and APIs in JavaScript

  Рет қаралды 144,617

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 141
@KalyanSingh-sd3jw
@KalyanSingh-sd3jw 2 жыл бұрын
Three Years later and i can't find a better vid than this for resolving cors.Thank you for the beginner friendly and clear explanations.
@kaxbyrita9279
@kaxbyrita9279 2 жыл бұрын
I’ve watched through the Coding Train videos for about a year now, and i’m still amazed that this quality stuff is just out there for everyone to enjoy for free. So huge thanks.
@Sondly
@Sondly 2 жыл бұрын
Just wanted to say thanks for this video. I was struggling with properly using a 3rd party API. Most tutorials on KZbin show how to use 3rd party APIs but not on how to setup a route so the user/client doesn't have access to your key! This was super valuable, in ANY REAL WORLD APPLICATION, you don't want the user to have access to that key! They could run up your bill etc! Thank you for the video.
@alpachino468
@alpachino468 3 жыл бұрын
I don't think I've ever seen a more cheerful, bubbly, coder before... I'm usually banging my head in pure frustration whenever I have to explain anything code-related to anyone, especially my bosses...
@Bradenxd12
@Bradenxd12 4 жыл бұрын
This was exactly the explanation I was looking for when it comes to CORS. It has been quite a confusing topic for me until now, excellent video!
@stevenrivadeneira990
@stevenrivadeneira990 3 жыл бұрын
This is an amazing series. A note regarding node-fetch as of 09/18/21: When I ran "npm install node-fetch", it gave me an error because node-fetch got upgraded to v3 and was wanting me to use "import" instead of "require". Make sure you update your .json to run node-fetch to version 2.0.0 if you see the same issue, and then it will work! Just paying it forward =) Thank you so much for these videos!!!
@mahmoudalsayed3041
@mahmoudalsayed3041 3 жыл бұрын
you are a legend :D
@aislayer2866
@aislayer2866 3 жыл бұрын
thanks sooooooooooooooooooooooooooooooooooooo much
@averagegodotenjoyer
@averagegodotenjoyer 3 жыл бұрын
Saved the day. Thanks.
@Roudrix118230
@Roudrix118230 2 жыл бұрын
Thank you very much, my dude
@dokidoki408
@dokidoki408 2 жыл бұрын
Man I should have read the comment section first I, lol. I also found a solution from stackoverflow on how to solve this problem, were you first uninstall fetch-node ("npm uninstall node-fetch") than install fetch-node v2 ("npm install node-fetch@2").
@oxygenmoldova
@oxygenmoldova 2 жыл бұрын
Man you are a treasure, thank you for your effort and all of the content that helped thousands of people to become better devs and struggle less with reading answers on stackoverflow
@kardes8528
@kardes8528 2 жыл бұрын
I want to say thanks for this and all other videos that you make. You make my days with whole those videos and the energy that you give us. You are the one of the bests who has all the attraction during the video with covering whole knowledge. Thank you Daniel with all my heart :)
@leerenae313
@leerenae313 3 жыл бұрын
Amazing this is such a great reference, short, concise and straight to the point! You're an amazing teacher thankx for putting this up for free ☺
@lexNwimue
@lexNwimue 2 жыл бұрын
Just seeing this channel for the first time (I wonder how it's possible that it took so long) and I already like how you explain things.
@alex75521
@alex75521 3 жыл бұрын
I'm working on a personal project to develop some web dev skills and this video just helped me immensely with a problem that i've been struggling with the last couple of days. Thank you!
@destinationveritas406
@destinationveritas406 5 жыл бұрын
Loving your video series on this topic so far. These videos have answered some questions I've had for a few days now that I haven't seen covered, or at least not in a clear manner, in other tutorials here on KZbin or even on Udemy. Keep up the fantastic work! Looking forward to watching more of your content.
@devilnight6610
@devilnight6610 5 жыл бұрын
Let's share this video to your friends who have the same passion! People : The Coding Train is Quality Contents KZbinr? Me : Yes.
@danfeinstein4424
@danfeinstein4424 2 жыл бұрын
"Dark Sky might change a little by the time you do this..." "Dark Sky is closing its API in 2023 and is no longer accepting new signups" lol
@aliaksandrhn1
@aliaksandrhn1 2 жыл бұрын
You make great videos and manage to do it in a fun way. Your personality is endearing. Thank you.
@alexsandergutierrezgoncalves
@alexsandergutierrezgoncalves 5 жыл бұрын
very cool these classes, it is difficult to find classes in Portuguese with a level of content well explained, so I watch English with subtitles kk
@heavygruff
@heavygruff 4 жыл бұрын
6 days left until I finish the requirements of my bachelors in software engineering and this refresher has been clearer than any of my instructors have been able to explain anything. Thank you. Happily hitting that subscribe button.
@piotrkalman1562
@piotrkalman1562 3 жыл бұрын
You are a magician. I've been looking for a solution for a week. Thank you so much :)
@godetarnaud1005
@godetarnaud1005 4 жыл бұрын
You guessed it right at the beginning of the video (well around 5min) dark sky api isn't an option anymore (it got brought by Apple and stopped allowing new sign ups) so I'll follow along using Open wheater api (it seems to be pretty similar and also ask to create an account) I'll comment again if it's a success and share the code on github if others are interested :D (btw this video series is awesome ! I really enjoyed going until there ^^)
@BrianKiddDevDesign
@BrianKiddDevDesign 2 жыл бұрын
Did it work using Open weather api?
@geoffwagner4935
@geoffwagner4935 Жыл бұрын
wow those rover cameras are amazingly clear
@jamesharrington2385
@jamesharrington2385 4 жыл бұрын
I really love this teaching format with the presentation style.
@lilrex2015
@lilrex2015 5 жыл бұрын
Still awesome, loving this video series. I vote for an OAUTH2 series at some point.
@sanchitverma2892
@sanchitverma2892 5 жыл бұрын
vote
@pablovm578
@pablovm578 5 жыл бұрын
Thanks to his advice i was able to do this from scratch play.google.com/store/apps/details?id=com.supercalamar.spaceout
@personzen8028
@personzen8028 2 жыл бұрын
old but gold, thank you
@heksqer1022
@heksqer1022 5 жыл бұрын
Love your way of teaching ! Looking forward to this series.
@kreddy241
@kreddy241 4 жыл бұрын
You are the best - I've learned so much from you. Appreciate your vids!
@JustinSulak
@JustinSulak 4 жыл бұрын
"The risk here is the Dark Sky API may not exist anymore...". *Foreshadowing*
@atharvparlikar8765
@atharvparlikar8765 3 жыл бұрын
these fucking bots
@swiftpotato6746
@swiftpotato6746 5 жыл бұрын
So I was trying to get data from an API and kept getting the CORS error. I was fetching from the client side but then I clicked and remebered this video! Thanks man :D
@matteol1356
@matteol1356 3 жыл бұрын
Dark Sky doesnt work anymore, I tried using another API from another web site called "open weather" and it works just fine, it also has an easy to read documentation!
@Ketrixx
@Ketrixx Жыл бұрын
04:30 - and the risk comes true, Dark Sky API doesn't exist anymore it was replaced by WeatherKit REST API
@annahri
@annahri 5 жыл бұрын
I hope there's someone like you (or you!) to have series on .NET CORE!
@vasyaqwe2087
@vasyaqwe2087 2 жыл бұрын
This helped so much! You're amazing!
@mkhalidumer
@mkhalidumer 5 жыл бұрын
Hi Daniel, thanks for being here always :) You have got a unique style of explaining, really appreciate your effort and time you put to create these tutorials :) may I ask a question, ? why node-fetch, why not request ?
@andrewwee8450
@andrewwee8450 3 жыл бұрын
"This is my API key" -> famous last words
@vvill-ga
@vvill-ga 4 жыл бұрын
If you are here for the tutorial to learn how to access an api with node.js the video starts at 5:00...
@SimonTiger
@SimonTiger 5 жыл бұрын
0:52 That's also true in the original Data Selfie App project!
@SimonTiger
@SimonTiger 5 жыл бұрын
So I don't know why you've done that in this project, but not in the Data Selfie one.
@punjabitech5546
@punjabitech5546 4 жыл бұрын
Thank You. Your channel is awesome
@yourteacher4353
@yourteacher4353 5 жыл бұрын
Thank you, Daniel. Top notch as always.
@prabhatsingh7713
@prabhatsingh7713 4 жыл бұрын
You are genius brother....!!
@m5amisi896
@m5amisi896 3 жыл бұрын
wow, I love you man. you saved me.
@anubislockward3750
@anubislockward3750 3 жыл бұрын
Just so you know...the Dark Sky API is no longer accepting new subscriptions.
@theodoredwernicki5729
@theodoredwernicki5729 2 жыл бұрын
Would you recommend any other weather api ?
@Pdrum2
@Pdrum2 8 ай бұрын
​@@theodoredwernicki5729I would use national weather service
@harjotsingh8671
@harjotsingh8671 2 жыл бұрын
I love this guy.
@andylib
@andylib 4 жыл бұрын
While watching (end of March 2020, during Corona) I just got the notification that apple acquired Dark Sky and will be shutting down these services: - the iOS app will be continued, website and android app will be shut down at the beginning of July 2020 - the API will be available until the end of 2021 .. what a bummer
@jamesjassi37
@jamesjassi37 4 жыл бұрын
could you please tell me how to find similar api ?
@BenjaminCarlson
@BenjaminCarlson 4 жыл бұрын
@@jamesjassi37 Here's a similar one I found that I'm going to be using to build the same thing but in flutter! www.climacell.co/weather-api/
@snacksy7754
@snacksy7754 4 жыл бұрын
This one is not as easy to use but run by a Norwegian government institution so will probably not disappear any time soon URL: api.met.no/weatherapi/locationforecast/2.0/compact? PARAMATERS: lat=60.10&lon=9.58 Tempature at: response.properties.timeseries[0].data.instant.details.air_tempature So yeah not as easy to use 😅
@fcs_96
@fcs_96 5 жыл бұрын
Nice lesson. Thanks
@ItsANoBrainer
@ItsANoBrainer 5 жыл бұрын
You should do a video in this series that utilizes Websockets using the WS javascript library! I think it would fit very well with the server theme.
@omars.162
@omars.162 5 жыл бұрын
Awesome video! Quick question, what is your terminal setup?
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
This workflow video series might help! kzbin.info/aero/PLRqwX-V7Uu6Zu_uqEA6NqhLzKLACwU74X
@PauloMiello
@PauloMiello 3 жыл бұрын
Thank you!!
@Programmerprith
@Programmerprith 3 жыл бұрын
Sir can you please suggest any other api like dark sky
@jonathan-._.-
@jonathan-._.- 5 жыл бұрын
In this case query params would probably be the preferred choice as you have 2 variables with the same 'importance' - for path paramers im usually expecting a sort of inheritance structure like weather/:country/:state/:city where each path paremeter is a subset of the one before
@yulinglin8508
@yulinglin8508 3 жыл бұрын
Save my life! Thanks a lot!!!
@c810549
@c810549 5 жыл бұрын
Hi , thank you so much for the great video. I’m also interested in learning „URL query string“, can you please point me out which video from you I could watch ? Thanks again for the amazing video.
@ViswasHaridas
@ViswasHaridas 5 жыл бұрын
Hey, you might be looking for 'Template literals', which is a feature introduced in ES6. Basically, you use backticks ( ` ) instead of quotes ( " ) to enclose your string, and you can put any js expression inside these: ${} Here's an example: const name = 'Chun'; const mood = 'happy' console.log(`I'm ${name} and I feel ${mood}!`); // I'm Chun and I feel happy! Docs: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
@joe_3y3s
@joe_3y3s 5 жыл бұрын
Could you do some of these vids with testing? There is such a lack of test driven tutorial vids out there!
@TheUnown4
@TheUnown4 2 жыл бұрын
does post and get really matter if you can get data via post response or post data via get request?
@getorvillized7499
@getorvillized7499 5 жыл бұрын
At the beginning of the video, it sounded like you were going to cover different hosting options. When are you going to go over that part? :)
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
Check the full playlist, it's the last one! kzbin.info/aero/PLRqwX-V7Uu6YxDKpFzf_2D84p0cyk4T7X
@getorvillized7499
@getorvillized7499 5 жыл бұрын
@@TheCodingTrain Ok, thanks.
@אביחימסלאווי
@אביחימסלאווי 4 жыл бұрын
Hi .. I build a server api one my local computer that only says hello . It works with request from postman an it works with request the from the browser ..but it doesn't work from a fetch call its show the same CROD error what to do .
@hayderjabur6258
@hayderjabur6258 4 жыл бұрын
so what is the best way to make a request from client side or server side ?
@Arisekiwi
@Arisekiwi 5 жыл бұрын
Hi Daniel, I am running into problems with the geo location. I can successfully run the "data selfie app" in Chrome and Firefox but it is not geo locating at all. And there are no errors in the console or in google developer tools. The app works for taking images and storing the data in the db but no location data... Weird. Have you had any problems? This issue also occurs in module3. Kind Regards.
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
hmmm, maybe you have some security settings on your computer that block the browser from geolocating?
@Arisekiwi
@Arisekiwi 5 жыл бұрын
​@@TheCodingTrain I thought about that, So I modified the settings in my browser to no avail. My next point of call is another laptop. Good news is though the image saving and comment check in side are working perfectly.
@kureysalp
@kureysalp 5 жыл бұрын
Tahnks for this video series they are awesom but I have a problem. When I typed ${variable} for parameters code takes it as a text its color not turning to blue. What is wrong in here?
@kureysalp
@kureysalp 5 жыл бұрын
I passed parameters with putting + between text and variable bur I wonder why ${} didn't work for me
@davidchen4495
@davidchen4495 4 жыл бұрын
Late reply but it’s back quote not single quote
@nvurt
@nvurt 3 жыл бұрын
@@davidchen4495 Thanks for adding this.
@yuriihusak1959
@yuriihusak1959 5 жыл бұрын
Hi! I love what you are doing, thanks! I was wondering why don't you use the advanced destructing ES6 feature for variables assignment, like: const { lanlon } = request.params; const [ lat, lon ] = lanlon.split(","); Mostly, it is shorter... But in spite of that your channel is still the most interesting on youtube
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
Thanks for the tips!
@gokselkucuksahin
@gokselkucuksahin 3 жыл бұрын
15:30 Or, we could use array destructuring; const [lat, lon] = request.params.latlon.split(',');
@NIronwolf
@NIronwolf 3 жыл бұрын
I'm thinking why bother to split it at all? Just pass in ${latlon} to the URL literal. A bunch of code to parse it then reassemble it exactly as it was.
@jonathan-._.-
@jonathan-._.- 5 жыл бұрын
I wonder if thers a procy pass endpoint for node ?
@mythic126
@mythic126 5 жыл бұрын
Gave me an idea.
@clementvanhecke2832
@clementvanhecke2832 5 жыл бұрын
Checkout Netatmo's weathermap, very similar !
@ujjavalsinghvlog7545
@ujjavalsinghvlog7545 5 жыл бұрын
woah we can save check ins to session or local storage instead database :O
@gabrielfono844
@gabrielfono844 2 жыл бұрын
I am not sure why I can't see the src folder
@gabrielfono844
@gabrielfono844 2 жыл бұрын
sorry mistake I solved my issues since I come from java background , I was little bit confused thanks your tutorials are amazing
@bpc1026
@bpc1026 4 жыл бұрын
Darksky does still exist in the same manner..... although it appears Apple just bought them and they have closed signups and the API will not be available starting 2022 :/
@kaizen9451
@kaizen9451 5 жыл бұрын
When's your 3rd book, Daniel? :P
@daybreak_eats
@daybreak_eats 3 жыл бұрын
Can someone help me understand why the request from the browser received the CORS error, but not from the server, which I presume was requested from the same public IP (origin) as the client? Or is that mentioned in an earlier video?
@RupertBruce
@RupertBruce 2 жыл бұрын
The server has its IP address and can be set up to hold the API key securely as explained in the video. The client is on the user's machine which has its own IP address and the browser restricts what the javascript has access to. You are in control of the server and you have the key. The user is in control of the client so it is not safe to send your key, just the data that the server acquires using your key.
@zicada7661
@zicada7661 5 жыл бұрын
Why don't darksky offer a POST endpoint i wonder. Seems easier to send lat and lon in the request-body instead of having to combine and then split the two parameters in the url.
@mart3323
@mart3323 5 жыл бұрын
there's a bunch of rules called the 'REST principles' that guide what the URL should look like and which verb (GET vs POST vs ...) you should use for each request Most API's try to follow that because existing tools take advantage of those semantics (for example browsers will warn you if you try to refresh a page opened with a POST request, telling you that it will resend the request and it might cause something to happen twice) The effort of having to split/join two numbers and put them in the right place is trivial enough that it's not even a consideration
@anibelle28
@anibelle28 4 жыл бұрын
Unfortunately, in June 2020 the Dark Sky API is not accepting any new sign-ups :(
@johncerpa3782
@johncerpa3782 5 жыл бұрын
Awesome
@asturnebur
@asturnebur 5 жыл бұрын
is this video upload again?
@yashchaudhary3544
@yashchaudhary3544 3 жыл бұрын
We can send lat and long from client to server via request parameters while making the get request. Someone correct me if I am wrong
@Varshakumari-uz8uo
@Varshakumari-uz8uo 3 жыл бұрын
Your teaching style is fabulous. But when I am writting same code to call third party API I am getting error.
@bacho7410
@bacho7410 5 жыл бұрын
How can I send something from server to client without client requesting it?
@stabgan
@stabgan 5 жыл бұрын
you need ro ask permission and also the client may need to be subscribed to webhooks
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
You could also investigate websockets
@someoneoutthere1866
@someoneoutthere1866 4 жыл бұрын
Apple discontinuing API since they bought DarkSky
@praful728
@praful728 5 жыл бұрын
Can you take session on npm Mqtt.
@DayV_
@DayV_ 5 жыл бұрын
Video on npm: kzbin.info/www/bejne/qWiTXompqslsjM0
@magdalenaduma1660
@magdalenaduma1660 4 жыл бұрын
Hi i try use different ApI from openweathermap.org/, ale path looks like this: `api.openweathermap.org/data/2.5/weather?appid=MY_KEY&lat=${lat}&lon=${long}`, how can i route parameters from this path without "/"? in express we have a hint, but i dont know how: Route path: /users/:userId/books/:bookId Request URL: localhost:3000/users/34/books/8989 req.params: { "userId": "34", "bookId": "8989" } Please help me, where am I must looking for answer? :)
@darkceptor44
@darkceptor44 5 жыл бұрын
Why do you use const so much, isn't it best practice to use var for variables that you're not gonna use outside of the functions?
@jochenpanjaer980
@jochenpanjaer980 5 жыл бұрын
Best practise is to use const and let.
@lilrex2015
@lilrex2015 5 жыл бұрын
var gives you global scope access and as such, you can screw with the assignment which can cause problems. Let is local scoped, and Const prevents reassignment. it is better to use Const.
@darkceptor44
@darkceptor44 5 жыл бұрын
@@lilrex2015 I thought var was actually local scope not global, anyway const will cause an error and interrupt the entire thing if it's null, I think using var and manually checking would be safer because you could make it run anyway and account for the error.
@lilrex2015
@lilrex2015 5 жыл бұрын
@@darkceptor44 if the information if going to be dynamic whether that be from user input or just data manipulation you would ideally use Let over var, CONST is used when you know exactly what's coming in and want a permanent setting. So in a fetch, the URL for the destination server should normally be a const.
@jochenpanjaer980
@jochenpanjaer980 5 жыл бұрын
@@darkceptor44 if const turns out to be null, it is null for a good reason. you can then check for null of falsy data and handle it appropriately. data flow and documentation is important. without writing actual documentation, const gives you already a good insight that the data will not change. I use const about 10 times more often than let. And I (and my team) never use var.
@ivansakal1224
@ivansakal1224 5 жыл бұрын
Are we gonna see some Python content anytime soon?
@geoffwagner4935
@geoffwagner4935 Жыл бұрын
The mot important take away here , is the "cors", i really thought node.js just had a better fetch, turn out it' because it's a server not a client
@kjyhh
@kjyhh 5 жыл бұрын
Very basic technic of a client request and response to server and to another server. #nodejs
@geoffwagner4935
@geoffwagner4935 Жыл бұрын
i''ve done so many fetch i'm not even sure why i tried node-fetch lol
@Nola1222Piano
@Nola1222Piano 5 жыл бұрын
Cool video, love the concept! PS, could you please take a look in your email 🙃, would love to have the slack invite! 😉😊
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
look for members only post on the community tab with a link to a google form!
@Nola1222Piano
@Nola1222Piano 5 жыл бұрын
@@TheCodingTrain Thanks! Filled it in!
@Mmustafa-v4j
@Mmustafa-v4j 4 жыл бұрын
Noooooo Dark sky is no longer accepting new registrations.
@bluedragonn1
@bluedragonn1 4 жыл бұрын
I create my DarkWeather API 3 days before Apple boughts it
@geoffwagner4935
@geoffwagner4935 Жыл бұрын
More important 2023 than dark sky(meh it is important i did want to know who apple's api was), node.js has a convenient fetch now since one i in e6 and express is not. the fetch-node npm just become incredibly inconvenient now.
@kevinnjoroge8236
@kevinnjoroge8236 4 жыл бұрын
Dark Sky are no longer accepting new signups! daaaam!
@3litepker
@3litepker 4 жыл бұрын
Ah Americans lonjitude...
@akhileshpips
@akhileshpips 5 жыл бұрын
this guy must be so iritating in real lifee
@matthewsmith1571
@matthewsmith1571 3 жыл бұрын
yeah i know right? Imagine someone being passionate about something!? You must be a joy to hangout with
@akhileshpips
@akhileshpips 3 жыл бұрын
@@matthewsmith1571 you'd never know pasta face
2.1 Server-side with Node.js - Working with Data and APIs in JavaScript
18:17
Andro, ELMAN, TONI, MONA - Зари (Official Audio)
2:53
RAAVA MUSIC
Рет қаралды 8 МЛН
5 JavaScript API Key Mistakes (and how to fix them)
12:49
James Q Quick
Рет қаралды 80 М.
1.1: fetch() - Working With Data & APIs in JavaScript
15:39
The Coding Train
Рет қаралды 457 М.
2.2 Geolocation Web API - Working with Data and APIs in JavaScript
15:04
The Coding Train
Рет қаралды 202 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 1,3 МЛН
Build a Rest Api with NodeJS (JavaScript), Express, and PostgreSQL
1:07:53
National Weather Service REST API with Python
34:22
Eli the Computer Guy
Рет қаралды 5 М.
How to hide your API keys SAFELY when using React
24:45
Code with Ania Kubów
Рет қаралды 174 М.