Skip to content

Commit

Permalink
Create cookbook folder in guides
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltazore committed Mar 2, 2024
1 parent 18e6a8f commit 9aed9f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ First you need to install [`@ember-data/request`](https://github.com/emberjs/dat

Here is how your own `RequestManager` service may look like:

```js
```ts
import { LegacyNetworkHandler } from '@ember-data/legacy-compat';
import type { Handler, NextFn, RequestContext } from '@ember-data/request';
import RequestManager from '@ember-data/request';
import Fetch from '@ember-data/request/fetch';
import { LegacyNetworkHandler } from '@ember-data/legacy-compat';

const TestHandler = {
async request({ request }, next) {
console.log('TestHandler.request', request);

const newContext = await next(request);

/* eslint-disable no-console */
const TestHandler: Handler = {
async request<T>(context: RequestContext, next: NextFn) {
console.log('TestHandler.request', context.request);
const newContext = await next(Object.assign({}, context.request));
console.log('TestHandler.response after fetch', newContext.response);

return next(newContext);
return newContext as T;
},
};

Expand Down Expand Up @@ -103,7 +102,7 @@ Now you can start refactoring old code to use new APIs. You can start with the `
You most likely would need to add Auth Handler to your request manager to add `accessToken` to your requests.
Let's say you have your `accessToken` in the `session` service. Here is how you can add it to the request manager:

```js auth-handler.js
```js
import { inject as service } from '@ember/service';

export default class AuthHandler {
Expand Down
3 changes: 3 additions & 0 deletions guides/cookbook/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Cookbook

- [Incremental Adoption Guide](./incremental-adoption-guide.md)
1 change: 1 addition & 0 deletions guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- [Relationships](./relationships/index.md)
- [Requests](./requests/index.md)
- [Terminology](./terminology.md)
- [Cookbook](./cookbook/index.md)

0 comments on commit 9aed9f2

Please sign in to comment.