diff --git a/build/app.bundle.js b/build/app.bundle.js index fee1df9..e039ee7 100644 --- a/build/app.bundle.js +++ b/build/app.bundle.js @@ -63,7 +63,7 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ return __webpack_require__(__webpack_require__.s = 2); /******/ }) /************************************************************************/ /******/ ([ @@ -125,7 +125,8 @@ var Mortgage = function () { exports.default = Mortgage; /***/ }), -/* 1 */ +/* 1 */, +/* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; diff --git a/build/app.bundle.js.map b/build/app.bundle.js.map index 8d9c245..9b1802c 100644 --- a/build/app.bundle.js.map +++ b/build/app.bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 71264ee56fb5fabb88c9","webpack:///./js/mortgage2.js","webpack:///./js/main.js"],"names":["Mortgage","principal","years","rate","monthlyRate","Math","pow","monthlyPayment","balance","amortization","y","interestY","principalY","m","interestM","principalM","push","document","getElementById","addEventListener","value","mortgage","innerHTML","toFixed","html","forEach","year","index","round"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;IChEqBA,Q;AACnB,oBAAYC,SAAZ,EAAuBC,KAAvB,EAA8BC,IAA9B,EAAoC;AAAA;;AAClC,SAAKF,SAAL,GAAiBA,SAAjB;AACA,SAAKC,KAAL,GAAaA,KAAb;AACA,SAAKC,IAAL,GAAYA,I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BC,IAA/B,CAAf;AACAc,aAASC,cAAT,CAAwB,gBAAxB,EAA0CI,SAA1C,GAAsDD,SAASd,cAAT,CAAwBgB,OAAxB,CAAgC,CAAhC,CAAtD;AACAN,aAASC,cAAT,CAAwB,aAAxB,EAAuCI,SAAvC,GAAmD,CAACnB,OAAO,EAAR,EAAYoB,OAAZ,CAAoB,CAApB,CAAnD;AACA,QAAIC,OAAO,EAAX;AACAH,aAASZ,YAAT,CAAsBgB,OAAtB,CAA8B,UAACC,IAAD,EAAOC,KAAP;AAAA,eAAiBH,8CAEjCG,QAAQ,CAFyB,iDAGhBtB,KAAKuB,KAAL,CAAWF,KAAKd,UAAhB,CAHgB,0KAOZc,KAAKd,UAPO,sBAOoBc,KAAKd,UAPzB,4HAUZc,KAAKf,SAVO,sBAUmBe,KAAKf,SAVxB,yHAcXN,KAAKuB,KAAL,CAAWF,KAAKf,SAAhB,CAdW,gDAehBN,KAAKuB,KAAL,CAAWF,KAAKlB,OAAhB,CAfgB,+BAAjB;AAAA,KAA9B;AAkBAS,aAASC,cAAT,CAAwB,cAAxB,EAAwCI,SAAxC,GAAoDE,IAApD;AAEH,CA5BD,E","file":"app.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 71264ee56fb5fabb88c9","export default class Mortgage {\r\n constructor(principal, years, rate) {\r\n this.principal = principal;\r\n this.years = years;\r\n this.rate = rate;\r\n }\r\n\r\n get monthlyPayment() {\r\n let monthlyRate = this.rate / 100 / 12;\r\n return this.principal * monthlyRate / (1 - (Math.pow(1/(1 + monthlyRate),\r\n this.years * 12)));\r\n }\r\n\r\n get amortization() {\r\n let monthlyPayment = this.monthlyPayment;\r\n let monthlyRate = this.rate / 100 / 12;\r\n let balance = this.principal;\r\n let amortization = [];\r\n for (let y=0; y {\r\n let principal = document.getElementById(\"principal\").value;\r\n let years = document.getElementById(\"years\").value;\r\n let rate = document.getElementById(\"rate\").value;\r\n let mortgage = new Mortgage(principal, years, rate);\r\n document.getElementById(\"monthlyPayment\").innerHTML = mortgage.monthlyPayment.toFixed(2);\r\n document.getElementById(\"monthlyRate\").innerHTML = (rate / 12).toFixed(2);\r\n let html = \"\";\r\n mortgage.amortization.forEach((year, index) => html += `\r\n \r\n ${index + 1}\r\n ${Math.round(year.principalY)}\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n ${Math.round(year.interestY)}\r\n ${Math.round(year.balance)}\r\n \r\n `);\r\n document.getElementById(\"amortization\").innerHTML = html;\r\n\r\n});\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/main.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap e55f194822094c9403e0?18b1","webpack:///./js/mortgage2.js","webpack:///./js/main.js"],"names":["Mortgage","principal","years","rate","monthlyRate","Math","pow","monthlyPayment","balance","amortization","y","interestY","principalY","m","interestM","principalM","push","document","getElementById","addEventListener","value","mortgage","innerHTML","toFixed","html","forEach","year","index","round"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;IChEqBA,Q;AACnB,oBAAYC,SAAZ,EAAuBC,KAAvB,EAA8BC,IAA9B,EAAoC;AAAA;;AAClC,SAAKF,SAAL,GAAiBA,SAAjB;AACA,SAAKC,KAAL,GAAaA,KAAb;AACA,SAAKC,IAAL,GAAYA,IAAZ;AACD;;;;wBAEoB;AACnB,UAAIC,cAAc,KAAKD,IAAL,GAAY,GAAZ,GAAkB,EAApC;AACA,aAAO,KAAKF,SAAL,GAAiBG,WAAjB,IAAgC,IAAKC,KAAKC,GAAL,CAAS,KAAG,IAAIF,WAAP,CAAT,EAC5B,KAAKF,KAAL,GAAa,E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,OAAZ,CAAoB,CAApB,CAAnD;AACA,QAAIC,OAAO,EAAX;AACAH,aAASZ,YAAT,CAAsBgB,OAAtB,CAA8B,UAACC,IAAD,EAAOC,KAAP;AAAA,eAAiBH,8CAEjCG,QAAQ,CAFyB,iDAGhBtB,KAAKuB,KAAL,CAAWF,KAAKd,UAAhB,CAHgB,0KAOZc,KAAKd,UAPO,sBAOoBc,KAAKd,UAPzB,4HAUZc,KAAKf,SAVO,sBAUmBe,KAAKf,SAVxB,yHAcXN,KAAKuB,KAAL,CAAWF,KAAKf,SAAhB,CAdW,gDAehBN,KAAKuB,KAAL,CAAWF,KAAKlB,OAAhB,CAfgB,+BAAjB;AAAA,KAA9B;AAkBAS,aAASC,cAAT,CAAwB,cAAxB,EAAwCI,SAAxC,GAAoDE,IAApD;AAEH,CA5BD,E","file":"app.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap e55f194822094c9403e0","export default class Mortgage {\r\n constructor(principal, years, rate) {\r\n this.principal = principal;\r\n this.years = years;\r\n this.rate = rate;\r\n }\r\n\r\n get monthlyPayment() {\r\n let monthlyRate = this.rate / 100 / 12;\r\n return this.principal * monthlyRate / (1 - (Math.pow(1/(1 + monthlyRate),\r\n this.years * 12)));\r\n }\r\n\r\n get amortization() {\r\n let monthlyPayment = this.monthlyPayment;\r\n let monthlyRate = this.rate / 100 / 12;\r\n let balance = this.principal;\r\n let amortization = [];\r\n for (let y=0; y {\r\n let principal = document.getElementById(\"principal\").value;\r\n let years = document.getElementById(\"years\").value;\r\n let rate = document.getElementById(\"rate\").value;\r\n let mortgage = new Mortgage(principal, years, rate);\r\n document.getElementById(\"monthlyPayment\").innerHTML = mortgage.monthlyPayment.toFixed(2);\r\n document.getElementById(\"monthlyRate\").innerHTML = (rate / 12).toFixed(2);\r\n let html = \"\";\r\n mortgage.amortization.forEach((year, index) => html += `\r\n \r\n ${index + 1}\r\n ${Math.round(year.principalY)}\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n ${Math.round(year.interestY)}\r\n ${Math.round(year.balance)}\r\n \r\n `);\r\n document.getElementById(\"amortization\").innerHTML = html;\r\n\r\n});\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/main.js"],"sourceRoot":""} \ No newline at end of file diff --git a/build/ratefinder.bundle.js b/build/ratefinder.bundle.js index de69011..907d163 100644 --- a/build/ratefinder.bundle.js +++ b/build/ratefinder.bundle.js @@ -63,32 +63,64 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ return __webpack_require__(__webpack_require__.s = 3); /******/ }) /************************************************************************/ -/******/ ({ - -/***/ 2: +/******/ ([ +/* 0 */, +/* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var url = "rates.json"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +var rates = [{ + "name": "30 years fixed", + "rate": "13", + "years": "30" +}, { + "name": "20 years fixed", + "rate": "2.8", + "years": "20" +}]; -fetch(url).then(function (response) { - return response.json(); -}).then(function (rates) { - var html = ''; - rates.forEach(function (rate) { - return html += "" + rate.name + "" + rate.years + "" + rate.rate + "%"; - }); - document.getElementById("rates").innerHTML = html; +var findAll = exports.findAll = function findAll() { + return new Promise(function (resolve, reject) { + if (rates) { + resolve(rates); + } else { + reject("No rates"); + } + }); +}; + +/***/ }), +/* 2 */, +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _rateServiceMock = __webpack_require__(1); + +var service = _interopRequireWildcard(_rateServiceMock); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +service.findAll().then(function (rates) { + var html = ''; + rates.forEach(function (rate) { + return html += '' + rate.name + '' + rate.years + '' + rate.rate + '%'; + }); + document.getElementById("rates").innerHTML = html; }).catch(function (e) { - return console.log(e); + return console.log(e); }); /***/ }) - -/******/ }); +/******/ ]); //# sourceMappingURL=ratefinder.bundle.js.map \ No newline at end of file diff --git a/build/ratefinder.bundle.js.map b/build/ratefinder.bundle.js.map index aa11e90..4fde978 100644 --- a/build/ratefinder.bundle.js.map +++ b/build/ratefinder.bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 71264ee56fb5fabb88c9?9f3c","webpack:///./js/ratefinder.js"],"names":["url","fetch","then","response","json","html","rates","forEach","rate","name","years","document","getElementById","innerHTML","catch","console","log","e"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;AChEA,IAAIA,MAAM,YAAV;;AAEAC,MAAMD,GAAN,EACKE,IADL,CACU;AAAA,SAAYC,SAASC,IAAT,EAAZ;AAAA,CADV,EAEKF,IAFL,CAEU,iBAAS;AACb,MAAIG,OAAO,EAAX;AACAC,QAAMC,OAAN,CAAc;AAAA,WAAQF,qBAAmBG,KAAKC,IAAxB,iBAAwCD,KAAKE,KAA7C,iBAA8DF,KAAKA,IAAnE,gBAAR;AAAA,GAAd;AACAG,WAASC,cAAT,CAAwB,OAAxB,EAAiCC,SAAjC,GAA6CR,IAA7C;AACD,CANL,EAOKS,KAPL,CAOW;AAAA,SAAKC,QAAQC,GAAR,CAAYC,CAAZ,CAAL;AAAA,CAPX,E","file":"ratefinder.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 71264ee56fb5fabb88c9","let url = \"rates.json\";\r\n\r\nfetch(url)\r\n .then(response => response.json())\r\n .then(rates => {\r\n let html = '';\r\n rates.forEach(rate => html += `${rate.name}${rate.years}${rate.rate}%`);\r\n document.getElementById(\"rates\").innerHTML = html;\r\n })\r\n .catch(e => console.log(e));\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/ratefinder.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap e55f194822094c9403e0","webpack:///./js/rate-service-mock.js","webpack:///./js/ratefinder.js"],"names":["rates","findAll","Promise","resolve","reject","service","then","html","forEach","rate","name","years","document","getElementById","innerHTML","catch","console","log","e"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;AChEA,IAAIA,QAAQ,CACR;AACI,YAAQ,gBADZ;AAEI,YAAQ,IAFZ;AAGI,aAAS;AAHb,CADQ,EAMR;AACI,YAAQ,gBADZ;AAEI,YAAQ,KAFZ;AAGI,aAAS;AAHb,CANQ,CAAZ;;AAaO,IAAIC,4BAAU,SAAVA,OAAU;AAAA,WAAM,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACxD,YAAIJ,KAAJ,EAAW;AACPG,oBAAQH,KAAR;AACH,SAFD,MAEO;AACHI,mBAAO,UAAP;AACH;AACJ,KAN0B,CAAN;AAAA,CAAd,C;;;;;;;;;;ACbP;;IAAYC,O;;;;AAEZA,QAAQJ,OAAR,GACKK,IADL,CACU,iBAAS;AACX,QAAIC,OAAO,EAAX;AACAP,UAAMQ,OAAN,CAAc;AAAA,eAAQD,qBAAmBE,KAAKC,IAAxB,iBAAwCD,KAAKE,KAA7C,iBAA8DF,KAAKA,IAAnE,gBAAR;AAAA,KAAd;AACAG,aAASC,cAAT,CAAwB,OAAxB,EAAiCC,SAAjC,GAA6CP,IAA7C;AACH,CALL,EAMKQ,KANL,CAMW;AAAA,WAAKC,QAAQC,GAAR,CAAYC,CAAZ,CAAL;AAAA,CANX,E","file":"ratefinder.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap e55f194822094c9403e0","let rates = [\r\n {\r\n \"name\": \"30 years fixed\",\r\n \"rate\": \"13\",\r\n \"years\": \"30\"\r\n },\r\n {\r\n \"name\": \"20 years fixed\",\r\n \"rate\": \"2.8\",\r\n \"years\": \"20\"\r\n }\r\n];\r\n\r\nexport let findAll = () => new Promise((resolve, reject) => {\r\n if (rates) {\r\n resolve(rates);\r\n } else {\r\n reject(\"No rates\");\r\n }\r\n});\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/rate-service-mock.js","import * as service from './rate-service-mock';\r\n\r\nservice.findAll()\r\n .then(rates => {\r\n let html = '';\r\n rates.forEach(rate => html += `${rate.name}${rate.years}${rate.rate}%`);\r\n document.getElementById(\"rates\").innerHTML = html;\r\n })\r\n .catch(e => console.log(e));\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/ratefinder.js"],"sourceRoot":""} \ No newline at end of file diff --git a/js/ratefinder.js b/js/ratefinder.js index 2943400..b99adbf 100644 --- a/js/ratefinder.js +++ b/js/ratefinder.js @@ -1,10 +1,9 @@ -let url = "rates.json"; +import * as service from './rate-service-mock'; -fetch(url) - .then(response => response.json()) +service.findAll() .then(rates => { - let html = ''; - rates.forEach(rate => html += `${rate.name}${rate.years}${rate.rate}%`); - document.getElementById("rates").innerHTML = html; + let html = ''; + rates.forEach(rate => html += `${rate.name}${rate.years}${rate.rate}%`); + document.getElementById("rates").innerHTML = html; }) .catch(e => console.log(e));