Alan Chen
Alan Chen

Reputation: 137

rn-fetch-blob: How do i make a post request with parameters in the body?

Hi this might be a silly question but I'm really confused on how to send a POST request with items in the body using rn-fetch-blob! https://github.com/joltup/rn-fetch-blob

This is my POST request code below but it is throwing an "Unable to symbolicate stack: the stack is null"

const data = 'guid='+guid+'&username='+username+'&pass='+password;

let response = await RNFetchBlob.config({ trusty: certificate })
                .fetch('POST', httpOrhttps + "://" + ipAddress + ":" + portNumber + 
                  "/setup/", RNFetchBlob.base64.encode(data))
                .catch(async (error) => { console.error(error); });

However my GET post works perfectly fine

let response = await RNFetchBlob.config({ trusty: certificate})
               .fetch('GET', httpOrhttps + "://" + ipAddress + ":" + httpPort + "/setup/guid=" + guid 
                             + "&username=" + username + "&pass=" + password)
              .catch(async (error) => { console.error(error); });

Dependencies:

"dependencies": {
    "@react-native-community/async-storage": "^1.11.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/bottom-tabs": "^5.7.1",
    "@react-navigation/drawer": "^5.8.5",
    "@react-navigation/material-bottom-tabs": "^5.2.13",
    "@react-navigation/native": "^5.7.0",
    "@react-navigation/stack": "^5.7.0",
    "react": "16.13.1",
    "react-native": "0.63.1",
    "react-native-device-info": "^5.6.3",
    "react-native-dropdown-picker": "^3.1.11",
    "react-native-elements": "^2.0.4",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-paper": "^4.0.0",
    "react-native-reanimated": "^1.9.0",
    "react-native-safe-area-context": "^3.1.1",
    "react-native-screens": "^2.9.0",
    "react-native-vector-icons": "^7.0.0",
    "rn-fetch-blob": "^0.12.0"
  },

Upvotes: 0

Views: 977

Answers (1)

Giovanni Esposito
Giovanni Esposito

Reputation: 11156

Ciao, very hard to understand why but most important where this error happens (I mean, occurs in rn-fetch-blob for sure but precisely where). I say this because, watching react native ExceptionsManager.js code, in function reportException, it returns The stack is null if doesn't receve a prettyStack (so we don't have a stack to analyze).

I found this but is old and there isn't a solution, except the 3 well known commands:

rm -rf ~/.rncache
watchman watch-del-all
npm start -- reset-cache

that you probably already tried.

Other thing: you have the very last version of rn-fetch-blob. You could try to dowgrade to 10 or 11 (you can do that because you have react-native 0.63).

That's it. I will add a comment to this answer if I will found other clues.

Upvotes: 1

Related Questions