picosanity
Advanced tools
Comparing version 1.0.1 to 1.0.2
'use strict'; | ||
var fetch = require('cross-fetch'); | ||
var enc = encodeURIComponent; | ||
@@ -9,3 +7,3 @@ var apiHost = 'api.sanity.io'; | ||
function PicoSanity(config) { | ||
function PicoSanity(config, fetcher) { | ||
if (!(this instanceof PicoSanity)) { | ||
@@ -16,2 +14,3 @@ return new PicoSanity(config); | ||
this.cfg = config; | ||
this.fetcher = fetcher; | ||
} | ||
@@ -27,3 +26,3 @@ | ||
var qs = getQs(query, params); | ||
return fetch('https://' + cfg.projectId + '.' + host + '/v1/data/query/' + cfg.dataset + qs).then(function (res) { | ||
return this.fetcher('https://' + cfg.projectId + '.' + host + '/v1/data/query/' + cfg.dataset + qs).then(function (res) { | ||
return res.json(); | ||
@@ -30,0 +29,0 @@ }).then(function (res) { |
{ | ||
"name": "picosanity", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Tiny Sanity client alternative should you only need to do queries", | ||
"main": "lib/client.js", | ||
"main": "lib/index.js", | ||
"browser": "lib/browser.js", | ||
"umd": "umd/client.js", | ||
@@ -33,3 +34,3 @@ "scripts": { | ||
"dependencies": { | ||
"cross-fetch": "^2.2.1" | ||
"node-fetch": "^2.1.2" | ||
}, | ||
@@ -45,4 +46,5 @@ "devDependencies": { | ||
"rimraf": "^2.6.2", | ||
"webpack": "^4.12.0", | ||
"webpack-command": "^0.2.1" | ||
} | ||
} |
@@ -10,4 +10,4 @@ # picosanity | ||
- Node.js >= 6 | ||
- Modern browsers (Edge, Chrome, Safari, Firefox etc) | ||
- IE if Promise is polyfilled | ||
- Modern browsers (Edge >= 14, Chrome, Safari, Firefox etc) | ||
- IE if [Promise](https://github.com/taylorhakes/promise-polyfill) and [fetch](https://github.com/github/fetch) is polyfilled | ||
@@ -14,0 +14,0 @@ ## Installation |
@@ -1,3 +0,1 @@ | ||
const fetch = require('cross-fetch') | ||
const enc = encodeURIComponent | ||
@@ -7,3 +5,3 @@ const apiHost = 'api.sanity.io' | ||
function PicoSanity(config) { | ||
function PicoSanity(config, fetcher) { | ||
if (!(this instanceof PicoSanity)) { | ||
@@ -14,2 +12,3 @@ return new PicoSanity(config) | ||
this.cfg = config | ||
this.fetcher = fetcher | ||
} | ||
@@ -36,3 +35,3 @@ | ||
const qs = getQs(query, params) | ||
return fetch(`https://${cfg.projectId}.${host}/v1/data/query/${cfg.dataset}${qs}`) | ||
return this.fetcher(`https://${cfg.projectId}.${host}/v1/data/query/${cfg.dataset}${qs}`) | ||
.then(res => res.json()) | ||
@@ -39,0 +38,0 @@ .then(res => res.result) |
@@ -1,2 +0,2 @@ | ||
const Client = require('../src/client') | ||
const Client = require('../src') | ||
@@ -3,0 +3,0 @@ const expectedDoc = { |
const path = require('path') | ||
module.exports = { | ||
entry: path.join(__dirname, 'lib', 'client.js'), | ||
entry: path.join(__dirname, 'lib', 'browser.js'), | ||
output: { | ||
@@ -6,0 +6,0 @@ library: 'PicoSanity', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
205394
19
145
10
+ Addednode-fetch@^2.1.2
- Removedcross-fetch@^2.2.1
- Removedcross-fetch@2.2.6(transitive)
- Removedwhatwg-fetch@2.0.4(transitive)