Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-geolocation

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-geolocation - npm Package Compare versions

Comparing version 2.0.0 to 2.1.3

example.js

22

index.js

@@ -9,5 +9,3 @@ /*

const { doRequest } = require ('httpreq');
/**

@@ -23,23 +21,25 @@ * Perform geolocation request

module.exports = async ({
module.exports = async ( {
key,
timeout = 5000,
}) => {
} ) => {
delete arguments[0].key;
delete arguments[0].timeout;
const url = `https://www.googleapis.com/geolocation/v1/geolocate?key=${key}`;
const options = {
method: 'POST',
url: `https://www.googleapis.com/geolocation/v1/geolocate?key=${key}`,
json: arguments[0],
timeout,
body: JSON.stringify( arguments[0] ),
signal: AbortSignal.timeout( timeout ),
};
const res = await doRequest (options);
const data = JSON.parse (res.body);
const res = await fetch( url, options );
const data = await res.json();
if (data.error) {
const error = new Error (data.error.message);
if ( data.error ) {
const error = new Error( data.error.message );
error.code = data.error.code;
error.reason = error.code;
error.errors = data.error.errors;

@@ -46,0 +46,0 @@

@@ -9,3 +9,3 @@ {

"description": "Google Maps Geolocation API for Node.js (unofficial)",
"version": "2.0.0",
"version": "2.1.3",
"repository": {

@@ -19,11 +19,13 @@ "type": "git",

"main": "index.js",
"dependencies": {
"httpreq": "^0.5.1"
},
"dependencies": {},
"devDependencies": {
"dotest": "^2.9.0"
"dotest": "^2"
},
"engines": {
"node": ">=12"
"node": ">=18"
},
"files": [
"example.js"
],
"runkitExampleFilename": "example.js",
"keywords": [

@@ -30,0 +32,0 @@ "accesspoints",

@@ -7,3 +7,3 @@ # google-geolocation

[![npm](https://img.shields.io/npm/v/google-geolocation.svg?maxAge=3600)](https://github.com/fvdm/nodejs-geolocation/blob/master/CHANGELOG.md)
[![npm](https://img.shields.io/npm/v/google-geolocation.svg?maxAge=3600)](https://www.npmjs.com/package/google-geolocation)
[![Build Status](https://github.com/fvdm/nodejs-geolocation/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/fvdm/nodejs-geolocation/actions/workflows/node.js.yml)

@@ -13,2 +13,3 @@ [![Coverage Status](https://coveralls.io/repos/github/fvdm/nodejs-geolocation/badge.svg?branch=master)](https://coveralls.io/github/fvdm/nodejs-geolocation?branch=master)

* [API documentation](https://developers.google.com/maps/documentation/geolocation/intro)
* [Release notes](https://github.com/fvdm/nodejs-geolocation/releases)

@@ -19,13 +20,13 @@

```js
const geo = require ('google-geolocation');
const geo = require( 'google-geolocation' );
function out (obj) {
console.dir (obj, {
function out( obj ) {
console.dir( obj, {
depth: null,
colors: true,
});
} );
}
// Get data
geo ({
geo( {
key: 'abc123',

@@ -37,8 +38,5 @@ wifiAccessPoints: [{

}],
})
.then (out)
.catch (err => {
out (err);
process.exit (1);
})
} )
.then( out )
.catch( out )
;

@@ -59,2 +57,3 @@ ```

[timeout] | number | `5000` | Request timeout in ms
... | mixed | | API parameters

@@ -65,8 +64,8 @@

```js
const geo = require ('google-geolocation');
const geo = require( 'google-geolocation' );
geo ({
geo( {
key: 'abc123',
timeout: 2000,
});
} );
```

@@ -73,0 +72,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc