Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
Created July 2, 2017 22:59
Show Gist options
  • Save nomoney4me/7e737c15f0374607b73161cafa2c98e8 to your computer and use it in GitHub Desktop.
Save nomoney4me/7e737c15f0374607b73161cafa2c98e8 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<script src="/js/vue.js"></script>
</head>
<body>
<div id="mycontainer">
<input id="search" type="Submit" value="Search for nearby restaurants" @click="search" />
<div id="err"></div>
<table>
<thead>
<th></th>
</thead>
<tbody>
<tr v-for="place in places">
<td>{{place.name}}</td>
<td>{{place.price}}</td>
</tr>
</tbody>
</table>
</div>
<script>
new Vue({
el:'#mycontainer',
data: {
places: []
},
methods: {
search: function() {
//navigator.geolocation.getCurrentPosition(success[, error[, options]])
navigator.geolocation.getCurrentPosition(function(pos) {
fetch('/search', {
method:'POST',
body:JSON.stringify(pos)
}).then(res => res.json()).then(result => {
this.places = result.businesses
})
})
}
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment