Skip to content

Commit 68d80e9

Browse files
authored
Add timeout for HTTP requests (#12)
1 parent 7aa02bc commit 68d80e9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,12 @@ TuyaCloud.prototype.request = async function (options) {
237237
debug('Sending parameters:');
238238
debug(JSON.stringify(pairs));
239239

240-
const apiResult = await got(this.endpoint, {searchParams: pairs});
240+
const apiResult = await got(this.endpoint, {
241+
searchParams: pairs,
242+
timeout: {
243+
request: 10000
244+
}
245+
});
241246
const data = JSON.parse(apiResult.body);
242247

243248
debug('Received response:');

0 commit comments

Comments
 (0)