Created
October 21, 2017 16:25
-
-
Save codetricity/1745a8b7010e4ac90af7f3bb726b9d23 to your computer and use it in GitHub Desktop.
Spitcast API test with JavaScript, node and ExpressJS
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
const express = require('express') | |
const app = express() | |
var Client = require('node-rest-client').Client; | |
var client = new Client(); | |
var url = 'http://api.spitcast.com/api/spot/forecast/149' | |
var forecast; | |
app.get('/', function(req, res) { | |
client.get(url , function (data, response) { | |
// grab first element of array for testing | |
forecast = data[0] | |
// print to console for testing | |
console.log(forecast); | |
var message = "On " + forecast.date + " the wave height at " + forecast.spot_name + | |
" is " + forecast.size + " feet" | |
res.send(message); | |
}); | |
}) | |
app.listen(3000, function () { | |
console.log('Example app listening on port 3000') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment