- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Shyam Hande has Published 72 Articles
Shyam Hande
64 Views
Why requires express.js?Writing core node.js code to fetch request data and parsing it is complex enough. As we saw in previous posts, we wrote data and end event to get the simple request data.Express makes the process simpler. It helps developers to focus more on writing business logic instead of ... Read More
Shyam Hande
97 Views
In earlier example, we used debugger in vs code to check any logical error. In this article we will look into how to use debug console and restarting debugger automatically on changes.In debug console, we can also type an expression and evaluate its result beforehand. This is very useful in ... Read More
Shyam Hande
279 Views
Error types are −Syntax errorRuntime errorLogical errorSyntax error −These are easy to find as most of the development tools like visual code studio shows red lines whenever there is a syntax error. The suggestion for resolution may be not be correct in tools but it gives an idea of what ... Read More
Shyam Hande
524 Views
Now, so far we saw how to create a node project with npm init command and also adding scripts to run application.Why third party libraries are requiredWe used core modules of node.js like http, fs etc which are available by default with node.js but working only with these core modules ... Read More
Shyam Hande
260 Views
So far we are running our App.js using following command −Node App.jsWe can use npm scripts to run or debug our app.How to start a node projectCommand is − npm initAbove command will initiate a project, it will ask few questions about project name and starting file name etc.As we ... Read More
Shyam Hande
93 Views
In our earlier example of getting user input and storing it a file has only one file. But in real life scenarios, we will have to create multiple file to keep code simple and easy to read.Let’s see how to use module system in node.jsWe have App.js −const http = ... Read More
Shyam Hande
251 Views
Node.js uses only one JavaScript execution thread.Question is − how Node.js process multiple http or any other requests and there can be question on performance, security as well?Node.js starts event loop on application start and handles callback functions using it.Node.js maintains a worker pool. Long running operations are transferred to ... Read More
Shyam Hande
401 Views
Now, we have a file writing function writeFileSync in fs module as shown below −const requestBody = []; req.on('data', (chunks)=>{ requestBody.push(chunks); }); return req.on('end', ()=>{ const parsedData = Buffer.concat(requestBody).toString(); const username = parsedData.split('=')[1]; fs.writeFileSync('username.txt', username); //redirect res.statusCode=302; res.setHeader('Location', '/'); return res.end(); });Sync means ... Read More
Shyam Hande
104 Views
In earlier example in App.js , we saw how to parse data from request using data and end event.Code snippet below shows the if block for that −if(url === '/username' && req.method === 'POST'){ const requestBody = []; req.on('data', (chunks)=>{ requestBody.push(chunks); }); req.on('end', ... Read More
Shyam Hande
2K+ Views
Earlier in simple code example, we saw how to route a request and creating a file to input the test data.Now, we want to save the user entered input data into text file.How Node.js handles incoming request dataNode.js reads data in chunks means it uses streams to read data . ... Read More