rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.24k stars 844 forks source link

Axios request get blocked #1474

Closed DirkDiggler31 closed 3 years ago

DirkDiggler31 commented 3 years ago

Hello, i have an app which is working fine. But if i install the @react-native-mapbox-gl/maps with a version >7.2.0, my axios request is blocked and return "network error" this request is called in the login, before any other request. I really don't get it,if i delete the dependency everything works fine. Here's my code for my request :

 static async initDonneesAccueil(listeInit) {
    let username = listeInit[0];
    let password = listeInit[1];

    let headersPost = {
      "Content-Type": "application/x-www-form-urlencoded"
    }

    return await axios.post(global.link, qs.stringify({ 
      tokenMobile: null,
      keyConnect: null,
      formData : `username=${listeInit[0]}&password=${listeInit[1]}`,
      methode :  "initDonneesAccueil",
      etat: "init", 
  }),
   headersPost).then((res) => {

     if (res.data.status) {
       console.log(res.data)
       AsyncStorage.setItem("tokenMobile", res.data.tokenmsg);
       AsyncStorage.setItem("KeyConnect", res.data.keyconnect)
      return res.data.tokenmsg
     }
      else { Alert.alert( "Erreur Identifiants")}
    })
    .catch(err => console.log(err))

  }]

Thank you for your answer, have a nice day.

Version

Platform: Android
Platform OS: Android 9
Device: Huawei P Smart
Emulator/ Simulator: same problem
Dev OS: Windows 10
react-native-mapbox-gl Version: 8.0.0
React Native Version: 0.64.1
ferdicus commented 3 years ago

what about plain old fetch requests?

DirkDiggler31 commented 3 years ago

Yes it doesn't work neither, it may be because of my extranet's company, but i don't understand why it's working in version 7.2.0 without any issues.

ferdicus commented 3 years ago

I'm sorry, but you're the only one reporting this :(
Maybe you can create a reproducible setup with our /example app we could test with?

Thanks

jarrodyellets commented 3 years ago

I too am getting this issue, only in Android tho. iOS works fine. As with the original poster, it happens on the initial login...with a valid user name and password, we get the [Error: Network Error] error. Without the library, it works ok. I'm going to try and recreated it with /example to test with.

aminsaedi commented 3 years ago

I have same problem, any solution?

jarrodyellets commented 3 years ago

I found a temp fix that worked for me...see here: https://github.com/facebook/react-native/issues/29196

Basically add this to build.gradle:

api(platform("com.squareup.okhttp3:okhttp-bom:4.7.2"))
api("com.squareup.okhttp3:okhttp")
api("com.squareup.okhttp3:logging-interceptor")
ferdicus commented 3 years ago

can you please also fill this out:


    Platform: [e.g. Android, iOS]
    Platform OS: [e.g. Android 9, iOS 10]
    Device: [e.g. iPhone6]
    Emulator/ Simulator: [yes/ no]
    Dev OS: [e.g. OSX 11.0.1, Win10]
    react-native-mapbox-gl Version [e.g. 7.0.9]
    Mapbox GL version [e.g. 6.3.0]
    React Native Version [e.g. 0.59]

it was missing in the initial description

thanks

ferdicus commented 3 years ago

I'm marking this as upstream, I tried with the current master on the example application and was unable to reproduce this issue.

test code:

const getJokes = async () => {
  const jokes = await fetch('https://official-joke-api.appspot.com/jokes/ten');
  return await jokes.json();
}

const jokes = await getJokes();
console.log('>>>>>>', jokes);

which returned correct results

I also tried with the endpoint mentioned in issue https://github.com/facebook/react-native/issues/29196 by @jarrodyellets

also works

without a proper repo and fully filled out specs of the issue template, there is nothing more we can do from our side

closing this - we can reopen if new info emerges

zholmes1 commented 3 years ago

@ferdicus Consider that this is the same issue that I encountered with the okhttp versions being out of sync.

ferdicus commented 3 years ago

@ferdicus Consider that this is the same issue that I encountered with the okhttp versions being out of sync.

you heard the man - please try with master all :)