Adding chain catch function

This commit is contained in:
Nate Taylor
2019-10-23 20:16:04 -05:00
parent 9bbce6939a
commit f5196268c4
3 changed files with 12 additions and 1 deletions

View File

@@ -16,17 +16,19 @@
<button class="bg-green mr2" onclick="get()">Success GET</button> <button class="bg-green mr2" onclick="get()">Success GET</button>
<button class="bg-green mr2" onclick="getCatch()">Failed GET</button> <button class="bg-green mr2" onclick="getCatch()">Failed GET</button>
<button class="bg-green mr2" onclick="chain()">Promise Chain</button> <button class="bg-green mr2" onclick="chain()">Promise Chain</button>
<button class="bg-green mr2" onclick="chainCatch()">Chain Catch</button>
<button class="bg-green mr2" onclick="final()">Final Update</button> <button class="bg-green mr2" onclick="final()">Final Update</button>
</div> </div>
<div class="results w-50 ml4 mt4 pa4"> <div class="results w-50 ml4 mt4 pa4">
<h1>Results</h1> <h1>Results</h1>
</div> </div>
<script type="module"> <script type="module">
import { get, getCatch, chain, final } from "./src/consuming.mjs"; import { get, getCatch, chain, chainCatch, final } from "./src/consuming.mjs";
window.get = get; window.get = get;
window.getCatch = getCatch; window.getCatch = getCatch;
window.chain = chain; window.chain = chain;
window.chainCatch = chainCatch;
window.final = final; window.final = final;
</script> </script>
</body> </body>

View File

@@ -12,6 +12,10 @@ export function chain(){
setText('C'); setText('C');
} }
export function chainCatch(){
setText('C1')
}
export function final(){ export function final(){
setText('D'); setText('D');
} }

View File

@@ -1,4 +1,9 @@
export default function setText(text){ export default function setText(text){
const results = document.getElementsByClassName("results")[0].children[0]; const results = document.getElementsByClassName("results")[0].children[0];
results.innerHTML = text; results.innerHTML = text;
}
export function appendText(text){
const results = document.getElementsByClassName("results")[0].children[0];
results.innerHTML += text;
} }