Skip to content

Instantly share code, notes, and snippets.

@nabrown
Last active June 5, 2018 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabrown/10d1f53b1978e9adf6ad6c92ea176bfa to your computer and use it in GitHub Desktop.
Save nabrown/10d1f53b1978e9adf6ad6c92ea176bfa to your computer and use it in GitHub Desktop.
Instagram Gallery Vue javascript
var app = new Vue({
el: '#app',
data: {
access_token: "your access token here",
url: "https://api.instagram.com/v1/users/self/media/recent/",
username: "",
grams: [],
next_url: "",
error: false
},
computed: {
instapage() {
return 'https://www.instagram.com/' + this.username
}
},
methods: {
getGrams() {
axios.get(this.url + "?access_token=" + this.access_token)
.then(({data}) => {
this.grams = data.data
this.username = data.data[0].user.username
this.next_url = data.pagination.next_url
})
.catch(function (error) {
console.log(error)
this.error = true
});
},
getMoreGrams(){
axios.get(this.next_url)
.then(({data}) => {
this.grams = this.grams.concat(data.data)
this.next_url = data.pagination.next_url
})
.catch(function (error) {
console.log(error)
this.error = true
});
}
},
created() {
this.getGrams();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment