Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ^2.0.1 related updates #36

Merged
merged 1 commit into from
Jan 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ Default deserializer options are defined on the static property `Model.deseriali

### Model definition

From [v2.0.1](https://github.com/itsfadnis/jsonapi-client/releases/tag/v2.0.1), it is mandatory for a model to have `_type` defined as a static property.
`Model._type` is used to describe the [type of resource objects](https://jsonapi.org/format/#document-resource-object-identification).

```javascript
class Address extends Model {
static _type = 'addresses';

// Always set the base url of your resource on this property
static baseURL = '/addresses';

Expand All @@ -70,6 +75,8 @@ class Address extends Model {
}

class DriversLicense extends Model {
static _type = 'drivers-license';

// Specify url parameters for nested resources
static baseURL = '/people/:person_id/drivers_license';

Expand All @@ -90,6 +97,8 @@ class DriversLicense extends Model {
}

class Person extends Model {
static _type = 'people';

static baseURL = '/people';

constructor(args = {}) {
Expand All @@ -110,6 +119,8 @@ class Person extends Model {

```javascript
class Post extends Model {
static _type = 'posts';

static baseURL = '/posts';

constructor(args) {
Expand Down