In Express.js, you can directly use the req.query() method to access the string variables. As per the documentation, the req.param method only gets the route parameters, whereas the req.query method checks the query string parameters. For example, "?id=12" checks urlencoded body params.Syntaxreq.query( )Example 1Create a file with the name "reqQuery.js" and copy the following code snippet. After creating the file, use the command "node reqQuery.js" to run this code as shown in the example below −// req.query() Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); ... Read More
The req.acceptsLanguage() method returns the first accepted language out of the specified languages based on the request's Accept-Language HTTP header field. This method returns 'false' if none of the specified language is accepted.Syntaxreq.acceptsLanguage ( lang, [...] )Example 1Create a file with the name "reqLang.js" and copy the following code snippet. After creating the file, use the command "node reqLang.js" to run this code as shown in the example below −// req.acceptsLanguage(lang, [...]) Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); // Initializing the ... Read More
The req.acceptsCharsets() method returns the first accepted charset of the specified charset sets. These charsets are based on the request's Accept-Charset HTTP header field. By default, it returns 'false' if none of the specified charsets is accepted.Syntaxreq.acceptsCharsets ( charset, [...] )Example 1Create a file with the name "reqAcceptsCharsets.js" and copy the following code snippet. After creating the file, use the command "node reqAcceptsCharsets.js" to run this code as shown in the example below −// res.acceptsCharsets(lang, [...]) Method Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); ... Read More
The req.accepts() method checks if the specified content-types are acceptable by the request's Accept HTTP header fields. This method returns the best match, and returns False if none of the specified content types is acceptable.The type values can be a MIME type like application/json, or an extension name like json.Syntaxreq.accepts( types )Example 1Create a file with the name "reqAccepts.js" and copy the following code snippet. After creating the file, use the command "node reqAccepts.js" to run this code as shown in the example below −// req.accepts() Method Demo Example // Importing the express module var express = require('express'); // ... Read More
express.urlencoded() is a built-in middleware in Express.js. The main objective of this method is to parse the incoming request with urlencoded payloads and is based upon the body-parser.This method returns the middleware that parses all the urlencoded bodies.Syntaxexpress.urlencoded( [options] )ParametersFollowing are the different options available with this method −options −inflate − This enables or disables the handling of the deflated or compressed bodies. Default: truelimit − This controls the maximum size of the request body.extended − This option allows to choose between parsing the URL encoded data with the queryString Library or the qs Library.type − This determines the media ... Read More
A low-pressure mercury vapor gas discharge lamp that uses fluorescence effect to produce visible light is known as fluorescent lamp or fluorescent tube.There are some common faults in case of the fluorescent lamps. These faults, their reasons and treatment methods are described in the following table −Type of FaultReasons of FaultTreatment or Repairing MethodsThe fluorescent lamp does not start.Loose and defective holders.Defective fluorescent tube.Defective starter switch.Defective choke.Turn the tube through 90° and check the connections and holders.Replace the tube.Try another starter switch / replace the starter switch.Replace the choke.Fluorescent lamp blinking ON and OFFLoose contacts.Wrong circuit connections.Low supply voltageDefective starter.Defective ... Read More
For HTML5 Canvas degree symbol, try to run the following code − body { margin:5em; background:#eee; text-align:center } canvas { background:#fff; border:2px solid #ccc; display:block; margin:3em auto } var c = document.getElementsByTagName('canvas')[0]; c.width = c.height = 300; var context = c.getContext('2d'); context.font = "20px sans-serif"; context.fillText("212° Fahrenheit", 100, 100);
What is Butt Welding?Butt welding is one of the simplest and versatile resistance welding process. In the butt welding process, heat is produced by the contact resistance between two metal workpieces. The faces of the workpieces should be machined or edge prepared.The circuit diagram for butt welding process is shown in the figure.In butt welding, the two workpieces are brought together and mechanical pressure is applied along the axial direction by a spring.A welding transformer is used that is having larger number of turns in the primary winding and smaller number of turns in secondary winding.A heavy current is passed ... Read More
The process of deposition of an oxide film on a metal surface is known as anodizing. The anodizing is an electrolytic passivation process, mainly used to increase the thickness of the natural oxide layer on the surface of the metal.This process is called anodizing because the metal part to be treated forms the anode electrode of the electric circuit of the process. The anodizing increases the corrosion resistance and wear resistance and provides better adhesion for paint primers and glues as compared to the bare metal.Requirements of AnodizingThe anodizing of metals is used for the following requirements −To provide the ... Read More
An electric light bulb or lamp that produces light by heating a filament wire to a high temperature until it glows is known as incandescent bulb. The incandescent bulb was invented by an American inventor, named Thomas Alva Edison.The incandescent bulb is an electric lamp that works on the principle of incandescence that means it emits light by the heating of a filament. The incandescent lamps come in different sizes with different voltages and wattages.Construction of Incandescent LampThe construction and the parts of an incandescent lamp is shown in the figure below.The most important part of the incandescent lamp is ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP