Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed doGetUser example function name #319

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions blog/javascript-fake-api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const getUser = (id) =>
});

// usage
const doGetUsers = async (id) => {
const doGetUser = async (id) => {
try {
const result = await getUser(id);
console.log(result);
Expand All @@ -200,7 +200,7 @@ const doGetUsers = async (id) => {
}
};

doGetUsers('1');
doGetUser('1');
```

Next, creating an item. If not all information is provided for the new item, the API will throw an error. Otherwise a new identifier for the item is generated and used to store the new item in the pseudo database:
Expand Down Expand Up @@ -297,4 +297,4 @@ doDeleteUser('1');

We have implemented the entire fake API for a RESTful resource (here user resource). It includes all CRUD operations, has a fake delay and returns an asynchronous result. For the write operations, the API only returns an acknowledgment (boolean), however, you could also decide to return an identifier (e.g. identifier of the removed item) or an item (e.g. the created/updated item).

<LinkCollection label="This tutorial is part 1 of 2 in this series." links={[{ prefix: "Part 2:", label: "How to mock data in React with a fake API", url: "/react-mock-data/" }]} />
<LinkCollection label="This tutorial is part 1 of 2 in this series." links={[{ prefix: "Part 2:", label: "How to mock data in React with a fake API", url: "/react-mock-data/" }]} />