locate-user
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "locate-user", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Know Your Client/User's Location", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,10 +28,35 @@ # locate-user | ||
http.createServer(function (req, res) { | ||
const userLocation = locateUser(req); | ||
res.end(userLocation); | ||
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) | ||
```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.. | ||
@@ -38,0 +63,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6201
65