I cant hit my api through real device


#1

HELP ME PLS

i can hit my api through ionic cordova run browser , but when i try to debug and build it to mobile device , the api wasnt get hitted by my app… any one can help ?

heres my source code:

this.camera.getPicture(options).then((imageData) => {
let base64Image = ‘data:image/jpeg;base64,’ + imageData;
this.userPhoto = base64Image;
let loader = this.loadCtrl.create({
content: “Uploading…”,
});
loader.present();
let data = {
userId: this.userData.userId,
userPhoto: base64Image
}
console.log(data,‘untuk di upload’)
this.userService.changePicture(data).subscribe(res => {
loader.dismiss();
})
}, (err) => {
// Handle error
});

i try to upload from ionic native, but it keep error while using mobile but from postman or browser it works weell


#2

Have you added the rights in config ?


#3

i think i did

i have following this

but still cant reach my api, the only thing api that cant be reached is the one who has aws service on it


#4

Do you get any err while hitting the api?? If possible share a screenshot of your console.


#5

i try to upload smaller file image, it work, but when i pick the image taking from camera which is the size is more biggger than last one, it send error. is there is a maximun size to upload file to aws ? sorry for oot


#6

Can you share the error that you get while invoking api from the device?

Thanks and Regards
Anand Raj


#7

i made a handle in my server when something wrong it throw to the next one, but it keep throw there. some time it work, some time it doesnt when using real device


#8

do you convert it to base64 before uploading or using file uri??