Skip to content

Commit

Permalink
Update README fixing syntax error
Browse files Browse the repository at this point in the history
Echo can't be used in an expression, since it doesn't have a return value.
  • Loading branch information
tresbach authored Mar 8, 2025
1 parent a967aba commit 650e82f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async(fn () => fetch('https://example.com', [
'body' => json_encode(['key' => 'value']),
]))
->then(fn (ResponseInterface $response) => $data = $response->json()) // Success handler
->catch(fn (\Throwable $e) => echo "Error: " . $e->getMessage()); // Error handler
->catch(fn (\Throwable $e) => print "Error: " . $e->getMessage()); // Error handler

// The async operation is managed with start, pause, resume, and cancel controls
$task = async(fn () => fetch('https://example.com', [
Expand Down Expand Up @@ -193,7 +193,7 @@ async(fn () => fetch('https://example.com', [
'body' => json_encode(['key' => 'value']),
]))
->then(fn (ResponseInterface $response) => $data = $response->json()) // Success handler
->catch(fn (\Throwable $e) => echo "Error: " . $e->getMessage()); // Error handler
->catch(fn (\Throwable $e) => print "Error: " . $e->getMessage()); // Error handler
```

---
Expand Down Expand Up @@ -244,7 +244,7 @@ async(fn () => fetch()
->withToken('fake-bearer-auth-token')
->post('/posts'))
->then(fn (ResponseInterface $response) => $data = $response->json()) // Success handler
->catch(fn (\Throwable $e) => echo "Error: " . $e->getMessage()); // Error handler
->catch(fn (\Throwable $e) => print "Error: " . $e->getMessage()); // Error handler
```

---
Expand Down Expand Up @@ -282,7 +282,7 @@ async(fn () => ClientHandler::handle('POST', 'https://example.com', [
'body' => json_encode(['key' => 'value']),
]))
->then(fn ($response) => $data = $response->json())
->catch(fn ($e) => echo "Error: " . $e->getMessage());
->catch(fn ($e) => print "Error: " . $e->getMessage());
```

---
Expand Down Expand Up @@ -327,7 +327,7 @@ if ($response->ok()) {

$response = async(fn () => fetch('https://nonexistent-url.com'))
->then(fn ($response) => $response->json())
->catch(fn ($e) => echo "Error: " . $e->getMessage());
->catch(fn ($e) => print "Error: " . $e->getMessage());

echo $response;
```
Expand Down

0 comments on commit 650e82f

Please sign in to comment.