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

Commit

Permalink
Merge pull request #284 from aleclarson/fix/publish-result
Browse files Browse the repository at this point in the history
fix: align the `publish` result with its return type
  • Loading branch information
junhoyeo authored Jul 27, 2023
2 parents edbcba2 + f7c167b commit 949b13a
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 949b13a

Please sign in to comment.