This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"engines": { | |
"node": "8.9.4", | |
"npm": "5.6.0" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
applications: | |
- name: chowchow | |
memory: 512M | |
instances: 1 | |
random-route: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Community example of multiple requests with Axios... | |
function A() { | |
return axios.get(API + '/A'); | |
} | |
function B() { | |
return axios.get(API + '/B'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Axios | |
const btnAxios = document.querySelector('#btnAxios') | |
btnAxios.addEventListener('click', function() { | |
axios.get(API) | |
.then(function(res) { | |
PRICE.textContent = res.data.bpi.USD.rate + ' USD' | |
}) | |
.catch(function(err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery | |
$('#btnJquery').click(function() { | |
$.getJSON(API) | |
.done(function(data) { | |
$('#price').text(data.bpi.USD.rate + ' USD') | |
}) | |
.fail(function(err) { | |
console.log(err) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fetch | |
const btnFetch = document.querySelector('#btnFetch') | |
btnFetch.addEventListener('click', function() { | |
fetch(API) | |
.then(function(res) { | |
res.json() | |
.then(function(data) { | |
PRICE.textContent = data.bpi.USD.rate + ' USD' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// XHR | |
const btnXHR = document.querySelector('#btnXHR') | |
btnXHR.addEventListener('click', function() { | |
let XHR = new XMLHttpRequest() | |
XHR.onreadystatechange = function() { | |
if (XHR.readyState == 4 && XHR.status == 200) { | |
PRICE.textContent = JSON.parse(XHR.responseText).bpi.USD.rate + ' USD' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="style.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
</head> | |
<body> | |
<h1>Bitcoin Price Checker</h1> | |
<ul> | |
<li id="btnXHR">XHR</li> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const API = 'https://api.coindesk.com/v1/bpi/currentprice.json' | |
const PRICE = document.querySelector('#price') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function searchYelp(queryString, callback) { | |
let options = { | |
headers: {'Authorization': 'Bearer ' + APIKEY}, | |
hostname: APIHOST, | |
path: APIPREFIX + queryString, | |
port: 443 | |
} | |
https.get(options, function(res) { | |
res.setEncoding("utf8") | |
let body = "" |