Тёмный

8.4: RESTful Routes with Parameters - Programming with Text 

The Coding Train
Подписаться 1,7 млн
Просмотров 41 тыс.
50% 1

Опубликовано:

 

4 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 52   
@AnandBaburajan
@AnandBaburajan 4 года назад
I love you! This series is still helpful in 2020! I'm starting with React and Express and this helped me a lot with building an app with APIs and json files. I'm going to learn databases next. :D Thank you!
@cmntkxp
@cmntkxp 6 лет назад
Excellent ..just like watching cool cartoon so relaxed
@mennotech4145
@mennotech4145 8 лет назад
Great videos Daniel! I only learn c# at school, but I also like learning JavaScript. Your enthusiasm makes it so fun to watch.
@cimmik
@cimmik 6 лет назад
I've always imagined that you made these videos at the university, but after 12:48 when the puppy began barking, I got the impression that you are doing your magic in your home. Not that it matters to me at all.
@kamoroso94
@kamoroso94 8 лет назад
For your addWord callback, it would give a false negative if you used 0 as the score.
@c0mpuipf
@c0mpuipf 8 лет назад
yes, finally, I waited for this for a long time, Thanks for uploading
@IsaacAsante17
@IsaacAsante17 6 лет назад
You are so helpful! Thanks for all the knowledge you keep sharing!
@iamsachin619
@iamsachin619 3 года назад
you are an awesome teacher!
@brainz80
@brainz80 4 года назад
I know this is a old video, but someone watching this right now. Shiffman made one huge error with his test for if the word can be found inside of words in the searchWord -function. if (words[word]) will act as a false also if the score happens to be 0. To fix this use Objects built in function hasOwnProperty ex. if (words.hasOwnProperty(word)) which instead tells javascript to look inside words for a property (key) named whatever is given in word
@samhitajoshi
@samhitajoshi 3 года назад
app.get('/search/:word', (quest, ponse) => { let word = quest.params.word let message = {} if(words.hasOwnProperty(word)){ message = { status: 200, "word": word, "value": words[word] } } else{ message = { status: 404, "word": word, "msg": "No such word yet." } } ponse.send(message) });
@pranaypatil4451
@pranaypatil4451 6 лет назад
Thanks sir , this video is very helpful for me
@phillyjr
@phillyjr 6 лет назад
great videos!! i laugh and learn everytime
@dannyshf1993
@dannyshf1993 8 лет назад
are you going to do another coding challenge? i am a 22 year old university student and i started coding because of your coding challenge video, i really appreciate what you do
@parentshateme_
@parentshateme_ 4 года назад
dude, thank you so much!!!! i really enjoy listening to you, because youre the only teacher who has an actual soul
@Auschwitz34
@Auschwitz34 7 лет назад
Hello Man; The videos are very nice and very beautiful. Energies are magnificent. Will you shoot more videos about NodeJs?
@devvvvvvvvvvvv
@devvvvvvvvvvvv 8 лет назад
Your line traversing and editing is nothing short of mesmerizing. Any good resource to learn and build that skill?
@devvvvvvvvvvvv
@devvvvvvvvvvvv 8 лет назад
Chris Oh. Thanks dude............
@iyadzain6972
@iyadzain6972 8 лет назад
I like you style, you let me like JS and NodeJs. Could make Playlist talking about MEAN stack in specific please ?
@galorespider1
@galorespider1 8 лет назад
can you do a coding challenge on tetris? it would be a pretty long video but i think it would be really fun to watch
@knightrec869
@knightrec869 4 года назад
it gives me this error . if i run the code. internal/modules/cjs/loader.js:968 throw err; ^ Error: Cannot find module 'E: ode\exp.js'  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)  at Function.Module._load (internal/modules/cjs/loader.js:841:27)  at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)  at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
@bharatbhushan1353
@bharatbhushan1353 6 лет назад
wow imaging info. thanks for your time
@bboyjojo1988
@bboyjojo1988 5 лет назад
I have questions Why do you use 'GET' On adding data to '/add' route? Is it suppose to be done by 'POST'? Or it is ok to do all the CRUD operation in 'GET'? I am so confusing And also how to define the method of the request at the front-end?
@jordanmoore7298
@jordanmoore7298 4 года назад
I believe the GET is done for only demonstrative purposes. It’s better to use POST for this example, but since you can’t test that with just a URL it’s a little beyond this video. If we were using Postman or another HTTP application, we could test the route handler for POST, instead of using GET in a non ideal way. For your second question, look into HTML forms. The only Http verbs available to forms are GET and POST, but these can serve most of your needs for something simple.
@MarcosPeralta
@MarcosPeralta 5 лет назад
Can you upload in 1080p in the future? Great videos!
@TheCodingTrain
@TheCodingTrain 5 лет назад
Yes, my current videos are now 1080p!
@MarcosPeralta
@MarcosPeralta 5 лет назад
HA! I was watching an old one! thanks!@@TheCodingTrain
@LandonHughes2
@LandonHughes2 6 лет назад
I followed everything to a T but I'm not getting the parsed vs.raw clickable option :/ Can someone explain how-to?
@cimmik
@cimmik 6 лет назад
I got a CannotGet error and it took me almost an hour finding out, what was wrong. I've written: ​app.get('add/:word/:score', addWord); instead of ​app.get('/add/:word/:score', addWord);
@jamesharper5850
@jamesharper5850 6 лет назад
classic programming problem, you understand the general idea and the more complex process but you missed a forward slash. Spend 5 hours seeing if all the files are connected, check if node is properly downloaded, nothing works. You come back the next day and realise you added a forward slash by accident.
@debanandanayak5650
@debanandanayak5650 2 года назад
your just looking like professor from money heist😁
@ValchyGaming
@ValchyGaming 6 лет назад
Anybody else not getting raw and parsed buttons as well as organized json? Please help
@rishabhattri6055
@rishabhattri6055 6 лет назад
You need to download JSON formatter as a chrome extension
@kaistullich7098
@kaistullich7098 7 лет назад
How would you go about checking if the "word" parameter was missing? In your example you did "!score", but what about if the word is missing?
@jordanmoore7298
@jordanmoore7298 4 года назад
Hi- there’s no need to check for if the parameter :word is included, since that route will only be handled if there is a value for that parameter in the URL.
@albertlewis332
@albertlewis332 5 лет назад
words[word] = score; I understand most parts of the code, but I can not understand the code above. Can somebody tell me why the line above works? Thank you so much in advance.
@alexey_remizov
@alexey_remizov 5 лет назад
this code is adding "on the fly" new pair of key-value. word is key, score is value. Javascript allows that. And word is variable (string), that was assigned some lines above from data.word.
@hammednoibi1878
@hammednoibi1878 7 лет назад
pls i wrote this code and it showing cannot get for this URL (localhost:add/book) and i was expecting (score is required) var words = { "Rainbow": 5, "Unicorn": 3, "Doom": -3, "Goom": -2 }; var express = require('express'); var app =express(); app.get('/add/:word/:score', addWord) ; function addWord(request, response){ var data = request.params; var word = data.word; var score = Number(data.score); var reply; if( !score){ reply = { msg: "Score is required" } } else { words[word] = score; reply = { msg: "thank you for your word" } response.send(reply); } } app.get('/all', sendAll ) function sendAll(request, response){ response.send(words) } app.listen(1000);
@chiefvoldemort1321
@chiefvoldemort1321 7 лет назад
shouldn't app.listen should be in starting?
@iliketocode6986
@iliketocode6986 4 года назад
show us the puppies!!
@reidharward
@reidharward 7 лет назад
Could server.js save itself with the changes you are making to the hash table of words and weights?
@TheCodingTrain
@TheCodingTrain 7 лет назад
yup, keep watching I do this in the subsequent videos!
@reidharward
@reidharward 7 лет назад
Yes, and thank you for explaining routing in node. I guess I can't think of an instance where it would be better to actually change the variable in the .js file that is being executed at the moment by, perhaps loading the file into a string and splitting it where the variable ends, and then adding the data, joining the string and saving it. Just more of a thought experiment/hack than anything else.
@reidharward
@reidharward 7 лет назад
Have you heard of quines? en.wikipedia.org/wiki/Quine_(computing)
@AlexWohlbruck
@AlexWohlbruck 7 лет назад
Why don't you use anonymous functions with your app.gets? Just wondeirng
@kdljjw7468
@kdljjw7468 7 лет назад
I'm a newbie for node.js but what I've heard is to avoid callback hell.
@elknacer961
@elknacer961 6 лет назад
thnk you but what means word [ word ] ???
@elknacer961
@elknacer961 6 лет назад
usually index is a number but whay here is a word
@waleedkhan6052
@waleedkhan6052 8 лет назад
first comment.please reply
@TheCodingTrain
@TheCodingTrain 8 лет назад
hello and thanks for watching!
@jalalelhamdaoui76
@jalalelhamdaoui76 5 лет назад
ok hhh
@laracroft9079
@laracroft9079 8 лет назад
i have a crush on you ;)
Далее
8.3: RESTful Routes - Programming with Text
11:05
Просмотров 45 тыс.
I Built a SECRET Lamborghini Dealership!
33:02
Просмотров 10 млн
Learn JSON in 10 Minutes
12:00
Просмотров 3,2 млн
If __name__ == "__main__" for Python Developers
8:47
Просмотров 405 тыс.
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
8.2: HTTP Server with Express - Programming with Text
12:20
Coding Challenge 181: Weighted Voronoi Stippling
28:59
Просмотров 167 тыс.
Coding Challenge 180: Falling Sand
23:00
Просмотров 947 тыс.