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

573 views Asked by At

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'
        }
    }); 
1

There are 1 answers

7
SoF On BEST ANSWER

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')