Skip to content

Commit

Permalink
fix: repair calling api with data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisbouchez committed Dec 19, 2024
1 parent a992f49 commit 2a1391d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export class ClientCaller {
*/
const headers = new Headers();
headers.append('Authorization', `Bearer ${this.secret}`);
headers.append('Content-Type', 'application/json');
headers.append('Accept', 'application/json');

/**
* Compute body.
Expand All @@ -83,11 +85,16 @@ export class ClientCaller {
/**
* Call Fly.io's Machines API.
*/
const response = await fetch(url, {
headers,
method,
body,
});
let response: Response;
try {
response = await fetch(url, {
headers,
method,
body,
});
} catch (error) {
return new Failure(error as Error);
}

if (!response.ok) {
return new Failure(
Expand Down

0 comments on commit 2a1391d

Please sign in to comment.