Created
July 2, 2017 22:59
-
-
Save nomoney4me/7e737c15f0374607b73161cafa2c98e8 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
<!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