File tree 4 files changed +36
-5
lines changed
4 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,14 @@ have shorthands of using object and array literals.
281
281
Additionally, [ Entities] ( ../api/Entity.md ) themselves can specify [ nested] ( ../guides/nested-response.md ) [ Entities] ( ../api/Entity.md )
282
282
by specifying a [ static schema] ( ../api/Entity.md#schema ) member.
283
283
284
+ <Tabs
285
+ defaultValue="Entity"
286
+ values={[
287
+ { label: 'Entity', value: 'Entity' },
288
+ { label: 'Response', value: 'Response' },
289
+ ] }>
290
+ <TabItem value =" Entity " >
291
+
284
292
``` typescript
285
293
import { Entity } from ' @rest-hooks/endpoint' ;
286
294
@@ -311,6 +319,25 @@ class User extends Entity {
311
319
}
312
320
```
313
321
322
+ </TabItem >
323
+ <TabItem value =" Response " >
324
+
325
+ ``` json
326
+ {
327
+ "id" : 5 ,
328
+ "user" : {
329
+ "id" : 10 ,
330
+ "username" : " bob" ,
331
+ },
332
+ "title" : " Write some Entities" ,
333
+ "completed" : false
334
+ }
335
+ ```
336
+
337
+ </TabItem >
338
+ </Tabs >
339
+
340
+
314
341
[ Learn more] ( ../guides/nested-response.md )
315
342
316
343
### Data Representations
Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ values={[
21
21
<TabItem value =" fetch " >
22
22
23
23
``` typescript
24
- class AuthdResource extends Resource {
24
+ import { Resource } from ' @rest-hooks/rest' ;
25
+
26
+ abstract class AuthdResource extends Resource {
25
27
static getFetchInit = (init : RequestInit ): RequestInit => ({
26
28
... init ,
27
29
credentials: ' same-origin' ,
@@ -33,15 +35,17 @@ class AuthdResource extends Resource {
33
35
<TabItem value =" superagent " >
34
36
35
37
``` typescript
36
- import { Resource } from ' rest-hooks' ;
38
+ import { Resource } from ' @ rest-hooks/rest ' ;
37
39
import type { SuperAgentRequest } from ' superagent' ;
38
40
39
- class AuthdResource extends Resource {
41
+ abstract class AuthdResource extends Resource {
40
42
static fetchPlugin = (request : SuperAgentRequest ) =>
41
43
request .withCredentials ();
42
44
}
43
45
```
44
46
47
+ If you used the [ custom superagent fetch] ( ../guides/custom-networking#superagent )
48
+
45
49
</TabItem >
46
50
</Tabs >
47
51
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ and ensure the data is normalized and typed
254
254
correctly via the [ schema] ( ../api/Endpoint#schema-schema ) definition.
255
255
256
256
``` typescript
257
- import { Resource } from ' rest-hooks' ;
257
+ import { Resource } from ' @ rest-hooks/rest ' ;
258
258
259
259
export default class BirthdayResource extends BaseResource {
260
260
readonly id: string | undefined = undefined ;
Original file line number Diff line number Diff line change 18
18
#### ` resources/ProfileResource.ts `
19
19
20
20
``` typescript
21
- import { Resource } from ' rest-hooks' ;
21
+ import { Resource } from ' @ rest-hooks/legacy ' ;
22
22
23
23
export default class ProfileResource extends Resource {
24
24
readonly id: number | undefined = undefined ;
You can’t perform that action at this time.
0 commit comments