(Beginner here)
I'm trying to create an app in Vue.js that would let me interact with GitHub API. I tried to use vue-github-api at first, but because of troubles working with pagination I switched to octokat.js.
I tried to use the same template that was suggested in vue-github-api docs and just switch to the octokat.
For brevity I'll include this small sample:
<template>
<div class="row">
<div class="col-sm-3">
<div class="panel panel-default">
{{ user.name }}
</div>
</div>
</div>
</template>
<script>
export default {
data () {
return {
userData: {},
issuesList: {}
}
},
mounted: function () {
var Octokat = require('octokat')
var octo = new Octokat({
token: 'xxxxx'
})
octo.user.fetch(function (e, val) {
this.userData = Object.assign({}, val)
// or this.userData = val (not sure, which is correct)
})
},
computed: {
user: function () {
if (this.userData) {
return this.userData
}
return 'Uh-oh...'
}
}
}
</script>
<style></style>
What I'm getting is:
Uncaught TypeError: Cannot set property 'userData' of undefined
If I would do this:
this.userData = octo.user.fetch()
Then if i console.log it I get this:
[]
I just can't seem to be able to get the desired output out of the "fetch" command.
Has anybody dealt with something similar, or did you spot a glaring error?