FormData append not working

I’m trying to send a post request to an api. For some reason JSON.stringify is not working for my code and FormData either. Actually FormData is not appending the payload… After trying append data to it I get undefined.

const body = new FormData();
  console.log(body); // gets undefined
  body.append("url", url); // append payload
  console.log(body); // gets undefined as well
  var response =  this.http.post(this.sumApiUrl, body, {headers: headers})
    .map(res => <any>(res.json()).subscribe());

Does anyone know why FormData is appending the payload?

Hello are you using a template driven or model-driven form?

Ashley

1 Like

Honestly I don’t know! I’m newbie to ionic and angular 2. Is this important?