@@ -40,20 +40,19 @@ First you need to install [`@ember-data/request`](https://github.com/emberjs/dat
40
40
41
41
Here is how your own ` RequestManager ` service may look like:
42
42
43
- ``` js
43
+ ``` ts
44
+ import { LegacyNetworkHandler } from ' @ember-data/legacy-compat' ;
45
+ import type { Handler , NextFn , RequestContext } from ' @ember-data/request' ;
44
46
import RequestManager from ' @ember-data/request' ;
45
47
import Fetch from ' @ember-data/request/fetch' ;
46
- import { LegacyNetworkHandler } from ' @ember-data/legacy-compat' ;
47
-
48
- const TestHandler = {
49
- async request ({ request }, next ) {
50
- console .log (' TestHandler.request' , request);
51
-
52
- const newContext = await next (request);
53
48
49
+ /* eslint-disable no-console */
50
+ const TestHandler: Handler = {
51
+ async request<T >(context : RequestContext , next : NextFn ) {
52
+ console .log (' TestHandler.request' , context .request );
53
+ const newContext = await next (Object .assign ({}, context .request ));
54
54
console .log (' TestHandler.response after fetch' , newContext .response );
55
-
56
- return next (newContext);
55
+ return newContext as T ;
57
56
},
58
57
};
59
58
@@ -103,7 +102,7 @@ Now you can start refactoring old code to use new APIs. You can start with the `
103
102
You most likely would need to add Auth Handler to your request manager to add ` accessToken ` to your requests.
104
103
Let's say you have your ` accessToken ` in the ` session ` service. Here is how you can add it to the request manager:
105
104
106
- ``` js auth-handler.js
105
+ ``` js
107
106
import { inject as service } from ' @ember/service' ;
108
107
109
108
export default class AuthHandler {
0 commit comments