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

nordnet-next-api

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nordnet-next-api - npm Package Compare versions

Comparing version 4.1.4 to 4.2.0

82

lib/index.js

@@ -7,3 +7,3 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

@@ -32,6 +32,2 @@ exports.setConfig = setConfig;

var merge = function merge(one, two) {
return Object.assign({}, one, two);
};
var defaultHeaders = {

@@ -42,3 +38,3 @@ accept: 'application/json'

function postDefaultHeaders() {
return merge({ 'content-type': 'application/x-www-form-urlencoded' }, defaultHeaders);
return Object.assign({ 'content-type': 'application/x-www-form-urlencoded' }, defaultHeaders);
}

@@ -53,6 +49,6 @@

var config = {};
var configKeys = ['root'];
var configKeys = ['root', 'agent'];
function setConfig() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

@@ -72,6 +68,7 @@ configKeys.forEach(function (key) {

function get(url) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var options = {
var fetchOptions = Object.assign({
url: url,

@@ -81,12 +78,13 @@ params: params,

method: 'get'
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}
function post(url) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var options = {
var fetchOptions = Object.assign({
url: url,

@@ -96,19 +94,21 @@ params: params,

method: 'post'
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}
function postJson(url) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
return post(url, params, merge(headers, { 'Content-type': 'application/json' }));
return post(url, params, Object.assign(headers, { 'Content-type': 'application/json' }, options));
}
function put(url) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var options = {
var fetchOptions = Object.assign({
url: url,

@@ -118,19 +118,21 @@ params: params,

method: 'put'
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}
function putJson(url) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
return put(url, params, merge(headers, { 'Content-type': 'application/json' }));
return put(url, params, Object.assign(headers, { 'Content-type': 'application/json' }, options));
}
function del(url) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var options = {
var fetchOptions = Object.assign({
url: url,

@@ -140,5 +142,5 @@ params: params,

method: 'delete'
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}

@@ -184,2 +186,8 @@

if (options.agent) {
Object.assign(fetchParams, { agent: options.agent });
} else if (config.agent) {
Object.assign(fetchParams, { agent: config.agent });
}
return fetch(fetchUrl, fetchParams).then(validateStatus).then(saveNTag).then(processResponse);

@@ -242,3 +250,3 @@ }

function buildUrl(path) {
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var query = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];

@@ -265,3 +273,3 @@ var queryParams = query.length ? query.join('&') : '';

function isNotValidPath(url) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -286,3 +294,3 @@ return !!(url.match(regUrlParam) || []).map(function (key) {

function buildParams() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var params = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

@@ -289,0 +297,0 @@ return Object.keys(params).map(function (key) {

{
"name": "nordnet-next-api",
"version": "4.1.4",
"version": "4.2.0",
"description": "Nordnet nExt API Javascript client",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -166,3 +166,26 @@ # Nordnet nExt API Javascript client

### Passing custom HTTP agent
```js
import http from 'http';
import { get } from 'nordnet-next-api';
const agent = new http.Agent();
get('https://api.test.nordnet.se/next/2/markets/{market_id}', { market_id: 11 }, { 'Accept-Language': 'sv' }, { agent })
.then(({ status, data }) => console.log(status, data));
```
### Setting up default HTTP agent
```js
import http from 'http';
import api from 'nordnet-next-api';
const agent = new http.Agent();
api.setConfig({ agent });
get('https://api.test.nordnet.se/next/2/markets/{market_id}', { market_id: 11 }, { 'Accept-Language': 'sv' })
.then(({ status, data }) => console.log(status, data));
```
## Example projects

@@ -169,0 +192,0 @@

@@ -11,4 +11,2 @@ import es6Promise from 'es6-promise';

const merge = (one, two) => Object.assign({}, one, two);
const defaultHeaders = {

@@ -19,3 +17,3 @@ accept: 'application/json',

function postDefaultHeaders() {
return merge(
return Object.assign(
{ 'content-type': 'application/x-www-form-urlencoded' },

@@ -33,3 +31,3 @@ defaultHeaders

const config = {};
const configKeys = ['root'];
const configKeys = ['root', 'agent'];

@@ -47,4 +45,4 @@ export function setConfig(options = {}) {

export function get(url, params = {}, headers = {}) {
const options = {
export function get(url, params = {}, headers = {}, options = {}) {
const fetchOptions = Object.assign({
url,

@@ -54,9 +52,9 @@ params,

method: 'get',
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}
export function post(url, params = {}, headers = {}) {
const options = {
export function post(url, params = {}, headers = {}, options = {}) {
const fetchOptions = Object.assign({
url,

@@ -66,13 +64,13 @@ params,

method: 'post',
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}
export function postJson(url, params = {}, headers = {}) {
return post(url, params, merge(headers, { 'Content-type': 'application/json' }));
export function postJson(url, params = {}, headers = {}, options = {}) {
return post(url, params, Object.assign(headers, { 'Content-type': 'application/json' }, options));
}
export function put(url, params = {}, headers = {}) {
const options = {
export function put(url, params = {}, headers = {}, options = {}) {
const fetchOptions = Object.assign({
url,

@@ -82,13 +80,13 @@ params,

method: 'put',
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}
export function putJson(url, params = {}, headers = {}) {
return put(url, params, merge(headers, { 'Content-type': 'application/json' }));
export function putJson(url, params = {}, headers = {}, options = {}) {
return put(url, params, Object.assign(headers, { 'Content-type': 'application/json' }, options));
}
export function del(url, params = {}, headers = {}) {
const options = {
export function del(url, params = {}, headers = {}, options = {}) {
const fetchOptions = Object.assign({
url,

@@ -98,5 +96,5 @@ params,

method: 'delete',
};
}, options);
return httpFetch(options);
return httpFetch(fetchOptions);
}

@@ -140,2 +138,8 @@

if (options.agent) {
Object.assign(fetchParams, { agent: options.agent });
} else if (config.agent) {
Object.assign(fetchParams, { agent: config.agent });
}
return fetch(fetchUrl, fetchParams)

@@ -142,0 +146,0 @@ .then(validateStatus)

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