Skip to content

Commit

Permalink
Add upgrade guide
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Jun 3, 2024
1 parent b14b188 commit 1756048
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Upgrading to 4.0.0

## Constructors Of `FetchServer` and `Server` Take An Object

For `Server`:

```diff
import { Server } from 'fakerest';
import { data } from './data';

-const server = new Server('http://myapi.com');
+const server = new Server({ baseUrl: 'http://myapi.com' });
server.init(data);
```

For `FetchServer`:

```diff
import { FetchServer } from 'fakerest';
import { data } from './data';

-const server = new FetchServer('http://myapi.com');
+const server = new FetchServer({ baseUrl: 'http://myapi.com' });
server.init(data);
```

## Constructor Of `Collection` Take An Object

```diff
-const posts = new Collection([
- { id: 1, title: 'baz' },
- { id: 2, title: 'biz' },
- { id: 3, title: 'boz' },
-]);
+const posts = new Collection({
+ items: [
+ { id: 1, title: 'baz' },
+ { id: 2, title: 'biz' },
+ { id: 3, title: 'boz' },
+ ],
+});
```

0 comments on commit 1756048

Please sign in to comment.