deblockt / hal-rest-client

Typescript HAL Rest client
Apache License 2.0
25 stars 11 forks source link

Add support for arrays of links #33

Closed davestewart closed 5 years ago

davestewart commented 5 years ago

As-per #32, I looked to add support for arrays of links.

This seems to work for me on real world URLs.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.02%) to 98.951% when pulling 6d140341e4d075125067bcfb11276147cd6ee464 on davestewart:link-arrays into c5b637e8b30f247276eff860a9eee0ad5e3b1d31 on deblockt:master.

deblockt commented 5 years ago

can you add information on the README to document this enhancement

davestewart commented 5 years ago

Great! Thanks for responding so quickly.

There is also an omission in the docs, which I only realised about a week after using the library, that you don't need to use link() to get links - prop() also returns a link if it's the same name!

await sites.prop('site').fetch()
console.log(sites.prop('site').props)
{href: "https://spaceinvaders.bookingbug.com/api/v1/site", name: "DEV", companies: Array(1)}
await sites.link('site').fetch()
console.log(sites.link('site').props)
{href: "https://spaceinvaders.bookingbug.com/api/v1/site", name: "DEV", companies: Array(1)}
sites.prop('site').props === sites.link('site').props
// true

Do you want me to document that whilst I am at it?

I have some additional structural / process improvements for the docs; I can add all this in a separate PR if you like?

davestewart commented 5 years ago

Oh crap I missed an await here:

Want me to update that now?

deblockt commented 5 years ago

Thank you for documentation upgrde :)

davestewart commented 5 years ago

Don't forget to publish to NPM !

deblockt commented 5 years ago

travis should do that... But it failed because npm has changed :'( I have no time to look at this now...

davestewart commented 5 years ago

npm publish in the terminal should do the trick!

deblockt commented 5 years ago

this release has been published