I have no idea why I'm not able to parse this JSON file in JS using RequireJS.
var settings = require('https://api.jsonbin.io/b/5e9535d3634f8d782606be53');
var parsed = JSON.parse(settings);
var indexPar = document.createElement('p');
window.onload = testJSON();
function testJSON() {
indexPar.innerHTML = "Full name is " + parsed.fname + " " + parsed.lname + "\nExpiration Date is " + parsed.expdate + "\nCredit Card # is " + parsed.creditcardnumber + "\nCVV is " + parsed.cvv;
}
<script type="text/javascript" src="https://requirejs.org/docs/release/2.3.6/r.js"></script>
To my knowledge, it should show this on the main HTML page:
Full name is Harrison Reeves
Expiration Date is 01/23
Credit Card # is 1234 5678 9012
CVV is 000
window.onload = testJSON;window.onload = testJSON();will runtestJSON()and assign the result of calling that function (undefined in this case) towindow.onload... whereaswindow.onload = testJSON;will call the functiontestJSONon the window load event - you decide which is correctindexPar.innerHTML = .... etcsets the innerHTML of an element that you haven't yet inserted into the DOM ... so, nothing will display in the web page .... creating an element doesn't add it to the DOM for you, you have to decide where you want to put it