,

Body Parser का उपयोग करके आने वाले Requests की Parsing करें | Express JS Full Course in Hindi/Urdu #7

Posted by

Parsing Incoming Requests using Body Parser | Express JS Full Course #7

पार्सिंग इनकमिंग रिक्वेस्ट्स यूज़िंग बॉडी पार्सर | एक्सप्रेस जेएस पूरा कोर्स #7

Body parser is a middleware in Express JS that parses incoming request bodies before your handlers, available under the req.body property.

बॉडी पार्सर एक मिडलवेयर है जो एक्सप्रेस जेएस में है जो इनकमिंग रिक्वेस्ट बॉडी को पार्स करता है आपके हैंडलर्स से पहले, req.body प्रॉपर्टी के तहत उपलब्ध है।

To use body parser in Express JS, you need to install it using npm:

        
            npm install body-parser
        
    

After installing, you can include it in your Express JS application like this:

        
            var express = require('express');
            var bodyParser = require('body-parser');

            var app = express();

            app.use(bodyParser.urlencoded({ extended: false }));
            app.use(bodyParser.json());
        
    

With body parser, you can easily access the incoming request body in your route handlers like this:

        
            app.post('/login', function(req, res) {
                var username = req.body.username;
                var password = req.body.password;

                // Do something with username and password
            });
        
    

That’s it! You have now successfully parsed the incoming request body using body parser in your Express JS application.

0 0 votes
Article Rating

Leave a Reply

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x