-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable compat with service workers and v3 extensions
- Loading branch information
Showing
6 changed files
with
350 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var logger = require('../logger'); | ||
var _ = require('../../utility'); | ||
|
||
function makeFetchRequest(accessToken, url, method, data, callback, timeout) { | ||
var controller; | ||
var timeoutId; | ||
|
||
if(_.isFiniteNumber(timeout)) { | ||
controller = new AbortController(); | ||
timeoutId = setTimeout(() => controller.abort(), timeout); | ||
} | ||
|
||
fetch(url, { | ||
method: method, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-Rollbar-Access-Token': accessToken, | ||
signal: controller.signal | ||
}, | ||
body: data, | ||
}) | ||
.then((response) => { | ||
if (timeoutId) clearTimeout(timeoutId); | ||
return response.json(); | ||
}) | ||
.then((data) => { | ||
callback(null, data); | ||
}) | ||
.catch((error) => { | ||
logger.error(error.message); | ||
callback(error); | ||
}); | ||
} | ||
|
||
module.exports = makeFetchRequest; |
Oops, something went wrong.