'what's this weird : JSON Parse error: Unexpected identifier "Tunnel"

i was trying to fetch some data from the server to display in the react native app. it was worked before but i don't know what happened after, i added a console.log in the catch of fetch.. it showing me error like

JSON Parse error: Unexpected identifier "Tunnel" - node_modules/promise/setimmediate/core.js:37:14 in tryCallOne - node_modules/promise/setimmediate/core.js:123:25 in - ... 8 more stack frames from framework internals

fetch(`${this.props.baseUrl}/products?page=${this.state.page}&per_page=10`,{
    method:"get",
    headers:{
        AUTH_TOKEN: this.props.AUTH_TOKEN
    }
}).then(res=>res.json()).then(data=>{
    if(data.success==true){
        this.page++;
        this.props.toggleLoading();
        this.props.loadProducts(data.products);
    }
}).catch(err=>console.log(err)); //error here ..i dont know why that's throwing this kinda error 



Solution 1:[1]

For me it was forgetting to update the ngrok url I had specified in a variable. Updating it fixed the issue

Solution 2:[2]

This can also be the result of starting to use a VPN:

  • disconnect from the VPN
  • restart ngrok
  • use new ngrok url

Solution 3:[3]

Hi are you using dotenv for your env variables? If you are, I also had the same error and i found out it was because my env variables were not updating which caused the tunnel url to not be found. You can try running ur app using this command: expo r -c or refer to the solutions in this link https://github.com/zetachang/react-native-dotenv/issues/24

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 beyondtdr
Solution 2 pors
Solution 3 Roy Chan