Comparing version 1.1.0 to 1.2.0
@@ -27,4 +27,8 @@ 'use strict'; | ||
fetch (url, direction) { | ||
const request = fetch(url, typeof this.fetchOptions === 'function' ? this.fetchOptions(url) : this.fetchOptions) | ||
const fetchOptions = (typeof this.fetchOptions === 'function') ? this.fetchOptions(url) : this.fetchOptions; | ||
const fetchOptionsPromise = (fetchOptions && typeof fetchOptions.then === 'function') ? fetchOptions : Promise.resolve(fetchOptions); | ||
const request = fetchOptionsPromise | ||
.then(options => fetch(url, options)) | ||
this.promises[direction === 'next' ? 'push' : 'unshift'](request); | ||
@@ -31,0 +35,0 @@ |
{ | ||
"name": "fetch-link", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Fetch related content by following Link headers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
18
test.js
@@ -277,2 +277,20 @@ 'use strict'; | ||
}) | ||
it('has ability to pass in different options per fetch asynchronously', () => { | ||
return fetchLinks.all('http://domain.com?page=1', { | ||
fetch: function (url) { | ||
return Promise.resolve({ | ||
method: 'POST', | ||
headers: { | ||
page: url.split('?').pop() | ||
} | ||
}) | ||
} | ||
}) | ||
.then(res => { | ||
expect(fetchMock.calls('first')[0][1].headers.page).to.equal('page=1'); | ||
expect(fetchMock.calls('second')[0][1].headers.page).to.equal('page=2'); | ||
expect(fetchMock.calls('third')[0][1].headers.page).to.equal('page=3'); | ||
}) | ||
}) | ||
}) | ||
@@ -279,0 +297,0 @@ }) |
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
16699
425