I just released Ketting 2.3, the missing HATEOAS client for Javascript.

I last blogged about this project in June, so I thought it was worth
listing the most interesting recent changes.

Content- and Accept header improvements

In the past, the library used a configurable set of mime-types for the
Accept header, and some heuristics for the Content-Type headers. This has
been greatly improved.

If you’re following links in this format:

  "_links": {
    "next": { "href": "/next-hop", "type": "application/vnd.some-vendor+"}
<link rel="next" href="/next-hop" type="application/vnd.some-vendor+json" />
HTTP/1.1 200 OK
Link: </next-hop>; rel="next" type="application/vnd.some-vendor+json"

In each of those cases, the link embeds a hint for the content-type at this
new location.

When running the following on a resource, the GET request will now
automatically use that value fo the Accept header:

const resource = "..."; // Pretend this is a Ketting resource.
const nextResource = await resource.follow('next');

console.log(await nextResource.get()); // Will get a application/vnd.some-vendor+json Accept header.

Support for OAuth2 client_credentials grant

The library supported some OAuth2, specifically:

  • Simply supplying a Bearer token.
  • Using the password grant_type.

Now, the library also supports the client_credentials grant. The library now
also detects if no refresh_token was given, and will automatically
re-authenticate using the original grant_type, if this was the case.

No longer ships with a fetch() polyfill

When using the web-packed file, I noticed that a large part of the size of
the Ketting library was attributable to a polyfill for the Fetch API.

Every modern browser ships the Fetch API, so this no longer seemed needed. If
you do need to run Ketting on an older browser, you can simply provide your own
polyfill, such as the whatwg-fetch package.


For well-behaved servers, these changes should not have a negative impact.
Don’t forget to test.

To update, this should usually do it:

npm install ketting@2.3.0

Source link
thanks you RSS link
( http://feedproxy.google.com/~r/bijsterespoor/~3/4U5slpY1Wsc/)


Please enter your comment!
Please enter your name here