0

json response

{"imgs":["respons1","respons1","respons1","respons1","respons1"],"titles":["respos2","respos3","respos4","respos5","respos6","respos7"],"links":["link1","link2","link1","link2","link1","link2","link1","link2"]}

How i Map it

const html = data.map(user =>{
        return `
                <div class="card" style="width:400px">
                    <div class="card-body">
                      <h4 class="card-title">${user.titles}</h4>
                      <a href="${user.links}" class="btn btn-primary">See Profile</a>
                    </div>
                </div>`;
    }).join('');
    document.querySelector("#row").insertAdjacentHTML("afterbegin", html);

Please help , i want to map this json code but i am not able to make it render , i will be really gald if you help me.

  • If `data` is an object as you show in your response, you aren't able to use `map` method there. Are you sure it is just an object and not an array – ZloiGoroh Nov 16 '21 at 05:05
  • `map` thorugh one of the arrays and use the `i` paratmer to get the same index in other arrays: Something like: `data.imgs.map((img, i) => \` – adiga Nov 16 '21 at 05:12

0 Answers0