samedi 22 août 2020

JSON DECODE RETURNING EMPTY OBJECT FOR API CALL

I am building a project with angular 8 and laravel as the backend. I am sending a formData with a stringified object to my backend but when I decode the object and console to log, I get an empty object {}. What is wrong?

HERE IS MY FRONTEND FORMDATA

const imgKey:any = Object.values(this.images);
  for(let i=0;i<=this.bulkCount.number;i++){
    for(let j=0;j<imgKey[i].length;j++){
      formData.append(`image[]`, imgKey[i][j], JSON.stringify([{product_position: i, name: imgKey[i][j].name}]))
    }
  }

BACKEND

       return response()->json(json_decode($fileNameToStoreWithExt, true));

$fileNameToStoreWithExt is the stringified object which when I get when I console.log.

What is wrongenter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire