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

stock-info

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stock-info - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

43

index.js

@@ -1,2 +0,2 @@

const http = require('http');
const axios = require('axios');

@@ -12,30 +12,19 @@ const getSingleStockInfo = stock =>

const options = {
hostname: 'query1.finance.yahoo.com',
path: `/v7/finance/quote?symbols=${stock}`,
};
const url = `https://query1.finance.yahoo.com/v7/finance/quote?symbols=${stock}`;
return http.get(options, (res) => {
let data = '';
res.setEncoding('utf-8');
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
try {
data = JSON.parse(data);
if (
!data ||
!data.quoteResponse ||
!data.quoteResponse.result ||
data.quoteResponse.result.length === 0
) {
return reject(new Error(`Error retrieving info for symbol ${stock}`));
}
return resolve(data.quoteResponse.result[0]);
} catch (err) {
return reject(err);
return axios
.get(url)
.then((res) => {
const { data } = res;
if (
!data ||
!data.quoteResponse ||
!data.quoteResponse.result ||
data.quoteResponse.result.length === 0
) {
return reject(new Error(`Error retrieving info for symbol ${stock}`));
}
});
});
return resolve(data.quoteResponse.result[0]);
})
.catch(err => reject(err));
});

@@ -42,0 +31,0 @@

{
"name": "stock-info",
"version": "1.0.3",
"version": "1.1.0",
"description": "Node.js module to retrieve stock information from Yahoo Finance API",

@@ -9,3 +9,8 @@ "main": "index.js",

},
"keywords": ["stock", "price", "value", "information"],
"keywords": [
"stock",
"price",
"value",
"information"
],
"repository": "luizjr92/stock-value",

@@ -23,3 +28,6 @@ "author": {

"mocha": "^5.2.0"
},
"dependencies": {
"axios": "^0.18.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