Node.js Express Indian Bank Information Finder By IFSC Code Full Web App Deployed to Website Online 2020

Node.js Express Indian Bank Information Finder By IFSC Code Full Web App Deployed to Website Online 2020

 

 

Welcome folks today in this tutorial we will be deploying a real web app where we will be fetching indian bank information by the IFSC CODE. A special code which can be used to fetch information about the banks.

 

Get Started

 

 

In order to get started we will be using a node dependency called as ifsc

 

npm init -y

 

npm i ifsc express

 

Now after installing this dependency inside your node.js project

 

Create a express project by creating a index.js file like this and copy paste the following code into it

 

 

var ifsc = require('ifsc');
 
ifsc.validate('KKBK0000261'); // returns true
ifsc.validate('BOTM0XEEMRA'); // returns false
 
ifsc.fetchDetails('KKBK0000261').then(function(res) {
   console.log(res);
});
 
console.log(ifsc.bank.PUNB); // prints PUNB

 

 

 

 

JSON Response

 

 

 

{
"DISTRICT": "MANGALORE",
"BRANCH": "Karnataka Bank IMPS",
"NEFT": true,
"MICR": "NA",
"STATE": "KARNATAKA",
"IMPS": true,
"UPI": true,
"CENTRE": "NA",
"CITY": "DAKSHINA KANNADA",
"ADDRESS": "REGD. & HEAD OFFICE, P.B.NO.599, MAHAVEER CIRCLE, KANKANADY, MANGALORE - 575002",
"CONTACT": "2228222",
"RTGS": false,
"BANK": "Karnataka Bank",
"BANKCODE": "KARB",
"IFSC": "KARB0000001"
}

 

 

Now we will create a full web app where we will use express for that purpose create index.js file and copy paste the following code to it

See also  jQuery 360 Degree Panorama Image Full Screen View in Browser Using HTML5 and Javascript Full Project For Beginners

 

index.js

 

Before that install this dependency ejs like this

 

npm i ejs

 

 

const express = require('express')

const bodyParser = require('body-parser')

const ifsc = require('ifsc')

const PORT = 4000

const app = express()

app.set('view engine','ejs')

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

app.get('/',(req,res)=> {4

res.render('index',{title:'IFSC Code Bank Information Finder',response:'',data:false})

})

app.post('/ifsc',(req,res) => {
    var code = req.body.ifsc

    if(ifsc.validate(code)){
        ifsc.fetchDetails(code).then(function(response) {
            console.log(response);
            res.render('index',{title:'IFSC Code Bank Information Finder',response:response,data:true})
        });
    }
    else{

    res.send("IFSC Code is wrong")
    }
})

app.listen(PORT,() => {
    console.log("Your app is listening on Port 4000")
})

 

 

views/index.ejs

 

Now create a views folder inside your root directory and create a iindex.ejs file and copy paste the following code to it

 

 

<!DOCTYPE html>
<html>
  <head>
    <title><%=title%></title>
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    />
  </head>
  <body>
      <div class="container">
        <h1 class="text-center">
            IFSC Code Info Finder
        </h1>
        <form action="/ifsc" method="post" id="form">
            <div class="form-group">
                <label>IFSC Code:</label>
                <input class="form-control" required type="text" name="ifsc" placeholder="IFSC Code"/>
            </div>
            <div class="form-group">
                <button class="btn btn-danger btn-block">
                    Get Info
                </button>
            </div>
            <%if (data) { %>
                <table class="table table-striped">
                    <thead>
                      <tr>
                        <th>District</th>
                        <th>Branch</th>
                        <th>Micr Code</th>
                        <th>State</th>
                        <th>Address</th>
                        <th>Contact</th>
                        <th>Bank</th>
                        <th>Bank Code</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <td><%=response.DISTRICT%></td>
                        <td><%=response.BRANCH%></td>
                        <td><%=response.MICR%></td>
                        <td><%=response.STATE%></td>
                        <td><%=response.ADDRESS%></td>
                        <td><%=response.CONTACT%></td>
                        <td><%=response.BANK%></td>
                        <td><%=response.BANKCODE%></td>
                      </tr>
                    </tbody>
                  </table>
            <% } %>
   
        </form>
      </div>
</body>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</html>

 

See also  Node.js Tutorial to Extract Base or Root URL From Subdomain Website URL Using get-base-url Library in Javascript Full Project For Beginners

 

 

 

 

Leave a Reply