Skip to content

Commit

Permalink
docs: improve examples (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
singhAmandeep007 authored Feb 11, 2024
1 parent b43a2f1 commit 1d2f575
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getUser(id) {
In case `fetchUser()` throws an error, the entire `getUser()` function's scope will terminate. Because of this, it's recommended to implement error handling using `try`/`catch` block wrapping `await` expressions:

```js
function getUser(id)
function getUser(id){
let data = null

try {
Expand Down Expand Up @@ -48,7 +48,7 @@ npm install @open-draft/until
```js
import { until } from '@open-draft/until'

async function(id) {
async function getUserById(id) {
const { error, data } = await until(() => fetchUser(id))

if (error) {
Expand All @@ -74,11 +74,11 @@ interface UserFetchError {
message?: string
}

async function(id: string) {
async function getUserById(id: string) {
const { error, data } = await until<UserFetchError, User>(() => fetchUser(id))

if (error) {
handleError(error.type, error.message)
return handleError(error.type, error.message)
}

return data.firstName
Expand Down

0 comments on commit 1d2f575

Please sign in to comment.