Skip to content

Instantly share code, notes, and snippets.

@codetricity
Created October 21, 2017 16:25
Show Gist options
  • Save codetricity/1745a8b7010e4ac90af7f3bb726b9d23 to your computer and use it in GitHub Desktop.
Save codetricity/1745a8b7010e4ac90af7f3bb726b9d23 to your computer and use it in GitHub Desktop.
Spitcast API test with JavaScript, node and ExpressJS
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