Socket
Socket
Sign inDemoInstall

cc-api-next

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cc-api-next - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

34

index.js
const fetch = require('isomorphic-unfetch');
const Cookies = require('universal-cookie');
class Api {
constructor(props){
constructor(props) {
this.url = props.url;

@@ -18,3 +17,3 @@ this.secret = props.secret;

setToken(token){
setToken(token) {
this.headers['x-token'] = token;

@@ -25,3 +24,3 @@ }

if(config === undefined){
if (config === undefined) {
config = data || {};

@@ -31,3 +30,5 @@ data = undefined;

if(!config.method){
const { headers } = config;
if (!config.method) {
config.method = 'get';

@@ -41,15 +42,22 @@ }

if(options.method !== 'GET'){
if (options.method !== 'GET') {
options.body = JSON.stringify({ data });
}
const handleResponse = response => {
switch (headers['Content-Type']) {
case 'application/octet-stream':
case 'application/pdf':
return response.blob();
default:
return response.json();
}
};
return fetch(`${this.url}${path}`, options)
.then(response => {
return response.json()
.then(response => {
return response;
});
}).catch(e => {
.then(handleResponse).catch(e => {
return e;
});
}

@@ -89,4 +97,4 @@

module.exports = function(options) {
module.exports = function (options) {
return new Api(options);
};
{
"name": "cc-api-next",
"version": "1.0.10",
"version": "1.0.11",
"description": "cc api next",

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

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