Home > Net >  App getting Crashed while installing it for the first time in React Native
App getting Crashed while installing it for the first time in React Native

Time:10-23

ERROR TypeError: Restricted in strict mode, js engine: hermes is getting thrown when trying to import Axios for network request in react native application. The error gets removed when i'm trying to remove the import statement from the below code.

api.js

import axios from "axios";

    export default axios.create({
    
        baseURL:"https://.com/v3/test",
        headers:{
            Authorization:'Bearer fsdfsfsd'
        }
    }); 

CodePudding user response:

Try to downgrade the axios version.

yarn remove axios
yarn add [email protected]

If it is not getting listed from node modules when trying to import Axios, import the package as follows:

const axios = require('axios')
  • Related