-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow starknet.js in service workers
axios (which uses the `XMLHttpRequest` interface) isn't supported in service workers. instead, we can use `cross-fetch` which supports single js code for node, browser and react-native
- Loading branch information
Showing
4 changed files
with
93 additions
and
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
import axios from 'axios'; | ||
import * as AxiosLogger from 'axios-logger'; | ||
/* eslint-disable no-console */ | ||
import { register } from 'fetch-intercept'; | ||
|
||
jest.setTimeout(50 * 60 * 1000); | ||
|
||
if (process.env.DEBUG === 'true') { | ||
axios.interceptors.request.use(AxiosLogger.requestLogger, AxiosLogger.errorLogger); | ||
axios.interceptors.response.use(AxiosLogger.responseLogger, AxiosLogger.errorLogger); | ||
register({ | ||
request(url, config) { | ||
console.log('[fetch.request]', [url, config]); | ||
return [url, config]; | ||
}, | ||
|
||
requestError(error) { | ||
console.log('[fetch.requestError]', error); | ||
return Promise.reject(error); | ||
}, | ||
|
||
response(response) { | ||
console.log('[fetch.response]', response); | ||
return response; | ||
}, | ||
|
||
responseError(error) { | ||
console.log('[fetch.responseError]', error); | ||
return Promise.reject(error); | ||
}, | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.