Hi all, I’m trying to upload metadata to ipfs. I am using localStorage and document.cookie to get the url and save it in mysql. In the first try, the url is null and in the other attempts, the url comes with the previous value. How can i update and get last value ?
async function uploaddata(data) {
const buft = buffer.Buffer(JSON.stringify(data));
ipfs.add(buft, (err, result) => { // Upload buffer to IPFS
if (err) {
console.error(err)
return
}
var dataurl = https://ipfs.io/ipfs/${result[0].hash}
;
console.log(“Metadata Loaded”, dataurl)
localStorage.setItem(“baltar”, dataurl);
localStorage.removeItem(‘daltar’);
document.cookie = “meta_url=”;
var sevecen = “meta_url=”+dataurl;
alert(sevecen);
return “meta_url=”+dataurl;
})
}