const count = true;
let countValue = new Promise(function (resolve, reject) {
if (count) {
resolve("There is a count value.");
} else {
reject("There is no count value");
}
});
console.log(countValue);
let fetchSent = fetch("/test", {method:"POST", body: JSON.stringify({name:"NAME NAME NAME"}), headers: {'Content-type': 'application/json; charset=UTF-8'}});
const p1 = new Promise((resolve, reject) => {
resolve(fetchSent);
// or
// reject(new Error("Error!"));
})
return p1;
/*console.log(p1) will yield the fetch promise that was sent to you*/