twitter-api-browser-js 0.0.13 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/main.d.ts +5 -2
- package/dist/main.js +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,4 +4,4 @@ Look [example.ts](./example.ts);
|
|
|
4
4
|
|
|
5
5
|
notice: It doesn't work well with Bun or Deno due to compatibility issues.
|
|
6
6
|
|
|
7
|
-
<img
|
|
7
|
+
<img alt="example" src="./.github/assets/example.png" />
|
package/dist/main.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare class TwitterAPIBrowser {
|
|
|
39
39
|
* @param body - The body of the request
|
|
40
40
|
* @returns Response of the request
|
|
41
41
|
*/
|
|
42
|
-
graphql<T extends string = string>(method: string, path: string, body: LooseType): Promise<
|
|
42
|
+
graphql<T extends string = string>(method: string, path: string, body: LooseType): Promise<LooseType>;
|
|
43
43
|
/**
|
|
44
44
|
* Sends a request to the Twitter API
|
|
45
45
|
* @param operationName - The name of the operation to request
|
|
@@ -47,5 +47,8 @@ export declare class TwitterAPIBrowser {
|
|
|
47
47
|
* @param fieldToggles - The fields to toggle on or off in the operation
|
|
48
48
|
* @returns Response of the request
|
|
49
49
|
*/
|
|
50
|
-
request<T extends keyof TwitterOpenAPIModelsMapping = string>(operationName: T, variables: LooseType, fieldToggles?: Record<string, boolean>, features?: Record<string, LooseType> | null): Promise<
|
|
50
|
+
request<T extends keyof TwitterOpenAPIModelsMapping = string>(operationName: T, variables: LooseType, fieldToggles?: Record<string, boolean>, features?: Record<string, LooseType> | null): Promise<{
|
|
51
|
+
success: boolean;
|
|
52
|
+
response: SuccessResponse<T> | LooseErrorResponse;
|
|
53
|
+
}>;
|
|
51
54
|
}
|
package/dist/main.js
CHANGED
|
@@ -218,6 +218,16 @@ export class TwitterAPIBrowser {
|
|
|
218
218
|
delete body[key];
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
|
-
|
|
221
|
+
const response = await this.graphql(method, `/graphql/${queryId}/${operationName}`, body);
|
|
222
|
+
if (response.errors) {
|
|
223
|
+
return {
|
|
224
|
+
success: false,
|
|
225
|
+
response: response,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
success: true,
|
|
230
|
+
response: response,
|
|
231
|
+
};
|
|
222
232
|
}
|
|
223
233
|
}
|