Can't find variable: btoa
See original GitHub issueDescribe the bug Using Basic Auth with axios in an expo app causes this error. It was working before upgrading both axios and expo, not sure what is causing the issue but seems btoa function is not available in expo envirorment.
To Reproduce Make a get request with auth headers from an expo app
let axiosInstance = axios.create({
baseURL: 'http://example.com',
auth: {
username: 'user',
password: 'password'
}
});
axiosIstance.get('/path/to');
Environment:
- Axios Version 0.18.0
- expo 32.0.0
- react 16.5
Additional context/Screenshots
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:21
Top Results From Across the Web
React Native atob() / btoa() not working without remote JS ...
You can set atob and btoa as global variables on React Native. Then, you won't need to import them on each file you...
Read more >Can't find variable: btoa - Hybrid - CometChat Forum
Hi My app is using expo 35.0.0 with react native sdk-35.0.0 I can initialize cometchat and i can create the user When i...
Read more >[Resolved] Can't Find Variable btoa in Mobile Preview
Context: • I have a custom function that uses "btoa" to encode base64 certain fields (used in 2 pages) • The function works...
Read more >react native base64, referenceerror: can't find variable
Solved the current issue (Axios Removed btoa variable Polyfill) with these steps: (Used in React-Native Project) Install base-64 npm package, npmjs.com/package/ ...
Read more >Developers - Can't find variable: btoa - - Bountysource
Can't find variable : btoa ... I tried to install btoa and atob via npm but it is not working. See More. View...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I’m new in GitHub, however let me try to help. Solved the current issue (Axios Removed btoa variable Polyfill) with these steps: (Used in React-Native Project)
import {decode, encode} from ‘base-64’
if (!global.btoa) { global.btoa = encode; }
if (!global.atob) { global.atob = decode; }
Source : https://stackoverflow.com/questions/42829838/react-native-atob-btoa-not-working-without-remote-js-debugging.
Hopefully Helps.
Thanks.
put “axios”: “0.18.0” in project dependencies that’s worked for me