JSFiddle - React, Tailwind, and code Playground
by rowntreerob
HTML
<input type="button" id="basicFetchButton" value="Try it">
JavaScript
const url2 = 'https://warm-earth-97740.herokuapp.com/parse/files/nativpic.jpg';
const url1 = 'https://i.picsum.photos/id/866/200/300.jpg?hmac=rcadCENKh4rD6MAp6V_ma-AyWv641M4iiOpe1RyFHeI';
document.getElementById("basicFetchButton").addEventListener("click", function(){
console.log('Beg')
// Loading the jQuery code
fetch(url1, {
headers: { "Origin":"https://jsfiddle.net",
"Content-Type": " image/jpeg",
"Access-Control-Request-Headers":
"Origin, Content-Type"
}
})
.then(function (response) {
console.log('st2')
fetch(url2, {
method: 'POST',
headers: { "Origin":"https://jsfiddle.net",
"Content-Type": " image/png",
"X-Parse-Application-Id": "dDgpCbCGWqIojuPcym19Ov6vEkmBH8Nk90P3qovv",
"Access-Control-Request-Headers":
"Origin, Content-Type, X-Parse-Application-Id"
},
body: response.body // binary file object from init fetch
})
.then(res2 => {
res2.json().then( jsn => {console.log(JSON.stringify(jsn))})
})
});
});