Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9e06796

Browse files
committedApr 22, 2022
60 second timeout
1 parent 764fa5c commit 9e06796

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
 

Diff for: ‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twitter-api-sdk",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A TypeScript SDK for the Twitter API",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

Diff for: ‎src/request.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ export async function request({
4646
request_body,
4747
method,
4848
max_retries,
49-
base_url: baseUrl = "https://api.twitter.com",
49+
base_url = "https://api.twitter.com",
50+
headers,
5051
...options
5152
}: RequestOptions): Promise<Response> {
52-
const url = new URL(baseUrl + endpoint);
53+
const url = new URL(base_url + endpoint);
5354
url.search = buildQueryString(query);
5455
const isPost = method === "POST" && !!request_body;
5556
const authHeader = auth
@@ -58,17 +59,20 @@ export async function request({
5859
const response = await fetchWithRetries(
5960
url.toString(),
6061
{
61-
...options,
6262
headers: {
63-
...options.headers,
64-
"User-Agent": `twitter-api-typescript-sdk/1.0.3`,
63+
"User-Agent": `twitter-api-typescript-sdk/1.0.4`,
6564
...(isPost
6665
? { "Content-Type": "application/json; charset=utf-8" }
6766
: undefined),
6867
...authHeader,
68+
...headers,
6969
},
7070
method,
7171
body: isPost ? JSON.stringify(request_body) : undefined,
72+
// Timeout if you don't see any data for 60 seconds
73+
// https://developer.twitter.com/en/docs/tutorials/consuming-streaming-data
74+
timeout: 60000,
75+
...options,
7276
},
7377
max_retries
7478
);

0 commit comments

Comments
 (0)
Please sign in to comment.