-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { findRecord } from '@ember-data/json-api/request'; | ||
|
||
const { content: { data: user } } = await this.store.request(findRecord('user', '1')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const user = await this.store.findRecord('user', '1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Bring your own builder | ||
import { findRecord as edFindRecord } from '@ember-data/json-api/request'; | ||
|
||
async function findRecord(typeOrIdentifier, id, options) { | ||
const result = await edFindRecord(typeOrIdentifier, id, options); | ||
|
||
return result.content.data; | ||
} | ||
|
||
export default { | ||
findRecord | ||
}; | ||
|
||
// Somewhere in app | ||
const user = await this.store.findRecord('user', '1'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Replicate old on store methods | ||
import { findRecord } from '@ember-data/json-api/request'; | ||
import DataStore from '@ember-data/store' | ||
|
||
export default class Store extends DataStore { | ||
async findRecord(typeOrIdentifier, id, options) { | ||
const result = await this.request(findRecord(typeOrIdentifier, id, options)); | ||
// but you might want to return whole result object, as it has meta, errors, links, etc. | ||
return result.content.data; | ||
} | ||
} | ||
|
||
// Somewhere in app | ||
const user = await this.store.findRecord('user', '1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
title: Fetching Data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
title: Find Record | ||
description: | | ||
Examples here are shown for apps that use JSON:API. Apps using other paradigms should use the builders for REST or ActiveRecord if applicable, or author their own (or a new community lib!) if not. |