Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
fix: align the publish result with its return type
Browse files Browse the repository at this point in the history
This was a regression caused by 200ad48
  • Loading branch information
aleclarson committed Jul 27, 2023
1 parent edbcba2 commit f7c167b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions threads-api/src/threads-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,15 @@ export class ThreadsAPI {
}

const payload = `signed_body=SIGNATURE.${encodeURIComponent(JSON.stringify(data))}`;
const res = await axios.post(endpoint, payload, {

type Response = {
media: {
id: string;
};
status: 'ok';
};

const res = await axios.post<Response>(endpoint, payload, {
httpAgent: this.httpAgent,
httpsAgent: this.httpsAgent,
headers: this._getAppHeaders(),
Expand All @@ -1501,8 +1509,8 @@ export class ThreadsAPI {
console.debug('[PUBLISH]', res.data);
}

if (res.data['status'] === 'ok') {
return res.data;
if (res.data.status === 'ok') {
return res.data.media.id;
}

return undefined;
Expand All @@ -1524,7 +1532,7 @@ export class ThreadsAPI {
timeout: 60 * 1000,
...options,
});
if (res.data['status'] === 'ok') {
if (res.data.status === 'ok') {
return true;
}
return false;
Expand Down

0 comments on commit f7c167b

Please sign in to comment.