The image is not being posted to api in ionic

#1

I’m working on the ionic application which uses POST API. And I am feeding that POST API with an image/blob but not taking that image into it. If the api took the image then it’ll return a string as an output and it should be visible in the HomePage in ionic.

Here is the code.

givetoapi(){
  var uploadingImage = new Image();
  uploadingImage.src = "../assets/imgs/banana.jpg";
  let headers = new Headers();
  headers.append('content-type','image/*');
  let url = 'http://af46cff3.ngrok.io';
  let postData = JSON.stringify({
    key :'predimg',
    value :uploadingImage.src
  })
  let data:Observable<any> = this.http.post(url,postData)
  data.subscribe((result) => {
    console.log(result)
#2

So what exactly is not working?

The code you posted uses a variable downloadingImage that doesn’t seem to exist.

#3

yeah @Sujan12 i’ve changed that check that again.

The issue is the uploadingImage is not being taken by the POST API.

#4

What does that mean? Does the server not know what to do with what it receives? Doesn’t it receive anything? Doesn’t the code POST anything? Is the variable even empty before you try to post?

#5

it is not receiving the image i am sending through the application @Sujan12

#6

So the variable is filled, the app is correctly sending it, but the server is not receiving the it?
Then this is a server bug and has nothing to do with Ionic.