Comparing version 0.4.1 to 0.4.2
ChangeLog | ||
========= | ||
0.4.2 (2017-08-03) | ||
------------------ | ||
* #39: Making it easier to fire off custom HTTP requests on a resource using | ||
the Fetch API. You can now just provide the `init` argument without providing | ||
a url. | ||
0.4.1 (2017-07-07) | ||
@@ -5,0 +13,0 @@ ------------------ |
@@ -256,7 +256,22 @@ 'use strict'; | ||
if (typeof input === 'undefined') { | ||
// Nothing was provided, we're operating on the resource uri | ||
input = this.uri; | ||
} else if (typeof input === 'string') { | ||
// A uri as sting is provided, we're resolving it. | ||
input = url.resolve(this.uri, input); | ||
} else if (typeof input.url === 'string') { | ||
// A url is provided in the init object. | ||
input.url = url.resolve(this.uri, input.url); | ||
} else { | ||
input.url = url.resolve(this.uri, input.url); | ||
// The provided argument is untyped, so likely the init | ||
// parameter was put first. | ||
// Using the argument as the 'init' value | ||
init = input; | ||
// And using the current uri as the 'input' value. | ||
input = this.uri; | ||
} | ||
@@ -263,0 +278,0 @@ var request = new fetch.Request(input, init); |
{ | ||
"name": "restl", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Opiniated HAL client.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -9,4 +9,5 @@ const Client = require('../../lib/client'); | ||
let hal2; | ||
let client; | ||
before( async () => { | ||
const client = new Client('http://localhost:3000/hal1.json'); | ||
client = new Client('http://localhost:3000/hal1.json'); | ||
hal2 = await client.follow('next'); | ||
@@ -16,3 +17,3 @@ }); | ||
it('should return a response object', async() => { | ||
const response = await hal2.fetch('?foo=bar'); | ||
@@ -25,4 +26,4 @@ expect(response).to.have.property('status'); | ||
it('should also work when passing a Request object', async() => { | ||
const request = new Request('?foo=bar'); | ||
const request = new Request('?foo=bar'); | ||
const response = await hal2.fetch(request); | ||
@@ -34,2 +35,16 @@ expect(response).to.have.property('status'); | ||
it('should allow overriding the HTTP method', async() => { | ||
const response = await hal2.fetch({ method: 'PUT' }); | ||
expect(response).to.have.property('status'); | ||
expect(response.status).to.eql(204); | ||
}); | ||
after( async() => { | ||
// Clearing any changes. | ||
await client.getResource('/reset').post({}); | ||
}); | ||
}); |
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
46224
1095