Skip to content

Commit 9d573fc

Browse files
committed
fix: get container status
1 parent 2073387 commit 9d573fc

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/index.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ type Scope =
3838
| "threads_manage_replies"
3939
| "threads_read_replies";
4040

41-
interface ContainerStatus {
42-
status: "EXPIRED" | "ERROR" | "FINISHED" | "IN_PROGRESS" | "PUBLISHED";
43-
id: string;
44-
error_message?: string;
45-
}
41+
type ContainerStatus =
42+
| "EXPIRED"
43+
| "ERROR"
44+
| "FINISHED"
45+
| "IN_PROGRESS"
46+
| "PUBLISHED";
4647

4748
type TimePeriod = "day" | "week" | "days_28" | "lifetime";
4849

@@ -113,6 +114,12 @@ interface UserMetric {
113114
id: string;
114115
}
115116

117+
interface ContainerStatusResponse {
118+
status: ContainerStatus;
119+
id: string;
120+
error_message?: string;
121+
}
122+
116123
// Main response structure for Media Insights
117124
interface ThreadsMediaInsightsResponse {
118125
data: MediaMetric[];
@@ -361,16 +368,18 @@ export class ThreadsAPI {
361368
* @returns The status of the media container
362369
* @note Recommended querying a container's status once per minute, for no more than 5 minutes.
363370
*/
364-
async getMediaContainerStatus(containerId: string): Promise<ContainerStatus> {
371+
async getMediaContainerStatus(
372+
containerId: string,
373+
): Promise<ContainerStatusResponse> {
365374
const url = `${this.baseUrl}${containerId}`;
366375
const params = new URLSearchParams({
367376
fields: "status,error_message",
368377
});
369378

370379
try {
371-
const response = await this.makeRequest<ContainerStatus>({
380+
const response = await this.makeRequest<ContainerStatusResponse>({
372381
url,
373-
method: "POST",
382+
method: "GET",
374383
params,
375384
});
376385

0 commit comments

Comments
 (0)