JSFiddle - React, Tailwind, and code Playground
by Abid Akhtar
JavaScript
var myObj = {name: "John", age: 31, city: "New York"};
var promiseTest = new Promise(function (resolve) {
// JSON.parse will throw an error because of invalid JSON
// so this indirectly rejects
//resolve(JSON.parse(JSON.stringify(myObj)));
//resolve(JSON.parse(JSON.stringify(myObj)));
});
promiseTest.then(function (data) {
alert("It worked!" + data);
}, function (error) { //error handler
alert(" I have failed you: " + error);
});