Created
August 5, 2015 00:59
-
-
Save jchesterman/0d3b663fc05e0d3ee034 to your computer and use it in GitHub Desktop.
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
var React = require('react'); | |
var request = require('superagent'); | |
var Header = require('../../common/components/header.jsx'); | |
var Button = require('../../common/components/button.jsx'); | |
var App = React.createClass({ | |
getInitialState: function() { | |
return { | |
riding: '' | |
}; | |
}, | |
// Geocode, then send API query with coordinates | |
_onAddressSubmit: function() { | |
var postal = React.findDOMNode(this.refs.input).value; | |
var url = 'http://represent.opennorth.ca/postcodes/' + postal + '/'; | |
request | |
.get(url, function(error, response) { | |
console.log('Response: ' + response.text); | |
this.setState({riding: 'lol'}); | |
}); | |
// var address = React.findDOMNode(this.refs.input).value; | |
/* request.get('url', function(error, response) { | |
// do stuff with the response | |
request.get('otherurl', { | |
option: response.optionName | |
}, function(error, response) { | |
// do more shit | |
this.setState({riding: response.riding}) | |
}); | |
}); */ | |
}, | |
_renderRiding: function() { | |
if (!this.state.riding) { | |
return null; | |
} | |
return ( | |
<div className="pol-riding"> | |
<p>{this.state.riding.name}</p> | |
</div> | |
); | |
}, | |
render: function() { | |
return ( | |
<div className="pol-app pol-app-ridings"> | |
<Header isDark={true} items={[]} /> | |
<input ref="input" type="text" /> | |
<Button onClick={this._onAddressSubmit} text="Go" /> | |
{this._renderRiding()} | |
</div> | |
); | |
} | |
}); | |
module.exports = App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment