1.0.2 • Published 6 years ago

locate-user v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

locate-user

Know Your Client's Location

Build Status

Install

(This Requires Node 4.x or Later...)

npm install locate-user --save

API

locateUser(req)

  • req - REQUIRED: http/https server request object

Usage

'use strict';
const http = require('http');
const locateUser = require('locate-user');

http.createServer(function(req, res) {

    const userLocation = locateUser(req);
    userLocation
        .then(data => {
            res.setHeader('Content-Type', 'application/json');
            res.end(JSON.stringify(data));
        })
        .catch(error => {
            console.error(error)
        });
}).listen(3000);

Usage (Using Express.JS)

'use strict';
const express = require('express');
const locateUser = require('locate-user');

const app = express();

app.get('/', (req, res, next) => {
    const userLocation = locateUser(req);
    userLocation
        .then(data => res.json(data))
        .catch(next);
});

app.listen(3000)

Please Contribute And Improve It..

Thank You!