Last active
January 23, 2018 03:51
-
-
Save rcdelacruz/90f82ef5696ffc3eac8db7de952dba74 to your computer and use it in GitHub Desktop.
demo - hello world
This file contains 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 renderTemp(data) { | |
var el = document.getElementById('temperature'); | |
el.innerHTML = data.temperature + " °C"; | |
} | |
// replace with the endpoint created in your deployment. | |
var endpoint = 'http://localhost:3000/weather'; | |
fetch(endpoint, { mode: 'cors' }) | |
.then(function (resp) { | |
return resp.json(); | |
}) | |
.then(renderTemp); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>What is the temperature?</title> | |
<style> | |
h1, | |
h2 { | |
text-align: center; | |
font-family: sans-serif; | |
color: #333; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>What is the temperature?</h1> | |
<h2 id='temperature'>Checking...</h2> | |
<script src="app.js" charset="utf-8"></script> | |
</body> | |
</html> |
This file contains 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
module.exports.getWeather = (event, context, callback) => { | |
const data = { temperature: 19.2 }; | |
const response = { | |
statusCode: 200, | |
headers: { | |
"Access-Control-Allow-Origin": "*", | |
}, | |
body: JSON.stringify(data) | |
}; | |
callback(null, response); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment