JSFiddle - React, Tailwind, and code Playground
by cdaringe
HTML
<script src="http://cdn.jsdelivr.net/es6-promise/0.1.1/promise.min.js"></script>
<ul id="log"></ul>
JavaScript
function post(txt){
var newItem = document.createElement("li");
newItem.innerHTML += txt;
document.getElementById('log').appendChild(newItem);
}
function go() {
tPromise = new Promise(function (resolve, reject) {
body = null;
body = undefined;
body = {results: 1};
if (!body || !body.results) reject(new Error("ZenDesk API rendered a bogus response"));
if (body.results.length === 0) resolve("ok");
post("I MADE IT THIS FAR! I SHOULDN'T HAVE IF I REJECTED OR RESOLVED!");
})
.then(post, function logE(e) {
post(e.message);
});
}
go();