Express JS Tutorial #12 - Middleware | Expressjs Tutorial For Beginners

  Рет қаралды 13,422

ARCTutorials

ARCTutorials

Күн бұрын

Learn express js tutorial for beginners, express js middleware tutorial, node express js tutorial, express js tutorial, express node js tutorial, express js tutorial 2020, express node js mongodb, express node js rest api, express node js tutorial for beginners, express node tutorial, express node mysql, express node js project, express node js mysql, express nodemon, express js crash course, express js project, express js api, expressjs tutorial for beginners, node express, node express mongodb tutorial, node express mysql, node express api
Node express project, node express mongodb, node express typescript, node express rest api, node express react, express js api, express js app, express js api tutorial, express js advanced, express js and mongodb tutorial, express js tutorial youtube, tutorial express js, express js mongodb, express js explained, express js mysql, express js routing, express js full course, express js routes tutorial, express js route params, express js routes in separate file, express js router example, express js route with parameter, express js mongodb crud, express js mongodb, express js mongodb insert, express js mongoose example, express js mongoose, express js mongoose tutorial, express js database tutorial, express js database
ExpressJS Tutorial For Beginners Playlist
• Express JS Tutorial Fo...
ExpressJS Tutorial For Beginners #1
• Express JS Tutorial #1...
ExpressJS Tutorial For Beginners #2
• Express JS Tutorial #2...
ExpressJS Tutorial For Beginners #3
• Express JS Tutorial #3...
ExpressJS Tutorial For Beginners #4
• Express JS Tutorial #4...
ExpressJS Tutorial For Beginners #5
• Express JS Tutorial #5...
ExpressJS Tutorial For Beginners #6
• Express JS Tutorial #6...
ExpressJS Tutorial For Beginners #7
• Express JS Tutorial #7...
ExpressJS Tutorial For Beginners #8
• Express JS Tutorial #8...
ExpressJS Tutorial For Beginners #9
• Express JS Tutorial #9...
ExpressJS Tutorial For Beginners #10
• Express JS Tutorial #1...
ExpressJS Tutorial For Beginners #11
• Express JS Tutorial #1...
ExpressJS Tutorial For Beginners #12
• Express JS Tutorial #1...
ExpressJS Tutorial For Beginners #13
• Express JS Tutorial #1...
ExpressJS Tutorial For Beginners #14
• Express JS Tutorial #1...

Пікірлер: 23
@derickasane8499
@derickasane8499 Жыл бұрын
nice tutorial sir. you are the best
@narendran-nn4ew
@narendran-nn4ew Жыл бұрын
i am getting this Error. Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client onst express=require("express"); const router=express.Router(); router.use("/",(req,res,next)=>{ req.headers["content-type"]='application/json'; console.log("api is calling"); next(); }); router.get("/",(req,res,next)=>{ res.send("header recived"+ req.headers["content-type"]); res.send("successfully getting data"); next(); }); router.use("/",(req,res)=>{ console.log("api is close"); }); router.get("/getting/:state/:city",(req,res)=>{ res.send("hi getting of "+req.params.state+req.params.city); }); router.get("/serch/:key([0-9]{4})",(req,res)=>{ res.send("hi getting of "+req.params.key); }); router.get("/serching/:key([a-zA-Z]{4})",(req,res)=>{ res.send("hi getting of "+req.params.key); }); router.get("*",(req,res)=>{ const errobj={ status:404, message:"URL is not found " }; res.json(errobj); }); module.exports=router; Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
@LH-ky6hh
@LH-ky6hh 3 жыл бұрын
Hi, I think it would be better for you to use the nodejs intellisense to avoid any syntax error, and make sure to npm i @types/node as well
@ARCTutorials
@ARCTutorials 3 жыл бұрын
That also sounds good (y)
@venkatagopiyadlapalli2353
@venkatagopiyadlapalli2353 2 жыл бұрын
Sir if you don't mine show on the browser instead of postman tool and also clumji
@bahadurkhan4918
@bahadurkhan4918 3 жыл бұрын
Sir nice tutorials👌. Please make a tutorial on how can I integrate angular app with nodejs express Just like real time development. Create an app from scratch of which main goal only showing how a real app developed.video forwarded is good or more helpful for us. I have one more doubt ng app has routing and nodejs as well, so how does they interact together. Again i request to you please make one more tutorial on this topic.
@ARCTutorials
@ARCTutorials 3 жыл бұрын
Sure Bahadur. I will be resuming the series from tomorrow.
@jayasreekarunanithi8487
@jayasreekarunanithi8487 Жыл бұрын
sir .. can you share notes link or git repo link?...thank you in adavance sir
@astroyussuf
@astroyussuf 3 жыл бұрын
when i try the same example, i see the middleware console print twice, looks like its called twice. how to resolve it?
@ARCTutorials
@ARCTutorials 3 жыл бұрын
Hi there. Can u pls send me screenshot of your code at soorya.aaradhya@gmail.com
@astroyussuf
@astroyussuf 3 жыл бұрын
@@ARCTutorials Sorry it was my mistake, instead of having the middleware functions inside the route pages, i kept it in the index.js and tried it. So it called the middleware function twice. First call happened when the endpoint is called and Second call when the "app.listen()" was called. when I placed the code in the route page it worked perfect. Thanks for your quick response
@rohitsachdeva4624
@rohitsachdeva4624 3 жыл бұрын
Sridhar please upload the later parts waiting for them.
@rohitsachdeva4624
@rohitsachdeva4624 3 жыл бұрын
And when we are doing console.log in the index.js then it is reflecting in the terminal but not on the browsers console.why that ?
@ARCTutorials
@ARCTutorials 3 жыл бұрын
More videos coming today Rohit. I will explain the console log too
@rohitsachdeva4624
@rohitsachdeva4624 3 жыл бұрын
@@ARCTutorials thanks Sridhar
@rohitsachdeva4624
@rohitsachdeva4624 3 жыл бұрын
I used the api end point of express js and used it in my angular project it gave me error of cors policy.can you suggest some ways to figure it out too.
@suryaways-the_sun_rise
@suryaways-the_sun_rise 3 жыл бұрын
This is how it use in real time sir
@ARCTutorials
@ARCTutorials 3 жыл бұрын
Thanks Surya
@himanshuarora1910
@himanshuarora1910 Жыл бұрын
what is difference between router.use ,,,router.get ,,,can u explain in detail please
@ramanraman6286
@ramanraman6286 2 жыл бұрын
bro please do file uploading in express
@ARCTutorials
@ARCTutorials 2 жыл бұрын
Coming up in next week
@johnbariquit6692
@johnbariquit6692 2 жыл бұрын
still not running with this code sir router.use('/', (req, res, next) => { req.headers['content-type']='application/json'; console.log("API called recieved"); next(); }); router.get('/', (req ,res, next) => { res.send("Headers recieved" + req.headers['content-type']); res.send("Get request for users"); next(); }); it says: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at new NodeError (internal/errors.js:322:7) at ServerResponse.setHeader (_http_outgoing.js:561:11) at ServerResponse.header (/Users/cb0011juan/Desktop/last year/expressJs/node_modules/express/lib/response.js:776:10) at ServerResponse.send (/Users/cb0011juan/Desktop/last year/expressJs/node_modules/express/lib/response.js:170:12) at /Users/cb0011juan/Desktop/last year/expressJs/routes/users.js:16:9 at Layer.handle [as handle_request] (/Users/cb0011juan/Desktop/last year/expressJs/node_modules/express/lib/router/layer.js:95:5) at next (/Users/cb0011juan/Desktop/last year/expressJs/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/Users/cb0011juan/Desktop/last year/expressJs/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/Users/cb0011juan/Desktop/last year/expressJs/node_modules/express/lib/router/layer.js:95:5) at /Users/cb0011juan/Desktop/last year/expressJs/node_modules/express/lib/router/index.js:281:22
@ashokchhetri8667
@ashokchhetri8667 2 жыл бұрын
its because you are sending response twice res.send("Headers recieved" + req.headers['content-type']); res.send("Get request for users"); so,It is giving you warning and remove the next() func from the second route handler middleware
Learn Express Middleware In 14 Minutes
14:48
Web Dev Simplified
Рет қаралды 389 М.
Пробую самое сладкое вещество во Вселенной
00:41
Did you believe it was real? #tiktok
00:25
Анастасия Тарасова
Рет қаралды 52 МЛН
버블티로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 115 МЛН
Express Middleware
19:50
Piyush Garg
Рет қаралды 78 М.
What is Observable | Observables | Angular 12+
14:16
procademy
Рет қаралды 147 М.
Пробую самое сладкое вещество во Вселенной
00:41