nicklandgrebe / active-resource.js

ActiveResource.js - API resource relational mapping in JavaScript
https://active-resource.js.org
MIT License
133 stars 20 forks source link

Allow reloading of resources without links #9

Closed nicklandgrebe closed 7 years ago

nicklandgrebe commented 7 years ago

Right now, a resource can only be reloaded if its links have been set (via JSON API query to a resource server)

But if we know @links['related'], which could be http://example.com/api/v1/products/, and the resource was built like Product.build(id: 1), its not hard to state that we can reload it by adding the id to the related link. This is useful for instantiating a resource with just an ID via server rendering, then reloading it to retrieve all its attributes at runtime.