salida+= <td> <button onclick='addFavourite(${rec.id},${rec.Title},${rec.Posterpath})'>Add to Favourites</button></td> ;
Esta es la función que toma argumentos y los agrega a la parte favorita en json, usando fetch, y también se muestra en la web como una tabla.
function agregarFavorito(valor,título,póster) {
let ind= itemarr.findIndex( ele=>ele.id==value); datastore= { "id": value, "Title" : title, "Posterpath": poster } fetch("http://localhost:3000/favourites",{ "method":"POST", "headers":{"content-type":"application/json"}, body:JSON.stringify(datastore) }) .then( res=> { console.log("Added"); itemarr2.push(datastore); displayproduct2(); } ) .catch( err=>console.log(err) )