Multipart Api not working after publishing code to expo

code is working fine until publish the app but after publishing multipart api not working at all.
please review my code, your help will be very thankful to me.

addClient() {
if (this.checkFieldsValidation(firstName, lastName, phoneNo)) {
let formdata = new FormData();
if (this.state.uri)
formdata.append(“profileImage”, { uri: this.state.uri, name: ‘photo.jpg’, type: ‘image/jpg’ })
else
formdata.append(“profileImage”, ‘’)
formdata.append(“businessId”, businessId)
formdata.append(“firstName”, firstName)
formdata.append(“lastName”, lastName)
formdata.append(“phoneNumber”, phoneNo)
formdata.append(“countryCode”, this.state.phoneCode)
alert(JSON.stringify(formdata))
fetch(language.en.BaseUrl+‘api/addBusinessClient’, {
method: ‘post’,
headers: {
‘Content-Type’: ‘multipart/form-data’,
‘authorization’: accessToken,
‘userId’: userId
},
body: formdata
}).then(response => response.json())
.then(responseJson => {
if (responseJson.code == 200) {
// this.props.navigator.push(‘listClientBooking’);

        self.props.hitGetClient(accessToken, businessId)

        self.props.navigator.pop();
        // alert(JSON.stringify(responseJson))
      } else {
        alert(JSON.stringify(responseJson))
      }
    })
    .catch(error => {
      return false;
    });
}

}

Hey @881deepakgupta this example is really hard to follow, partially because of the way its formatted.

It may be better for you to include the full sample in https://snack.expo.io so that someone can run the code and get a better understanding of the implementation details.

Off the top of my head, you could try making addClient an async function, putting an await infront of the fetch, and then inspecting the response so you have a better understanding of whats going wrong.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.