Mixin: GitLabAPI

GitLabAPI

A deadly simple Vue.js plugin to consume GitLab API.
Author:
License:
Source:
See:

Methods

(static) get(uri, params, fillIn, errorCb)

Issue a GET request on 'GitLabAPI_url/api/v4' with params and a variable to fill in
Parameters:
Name Type Description
uri String The GitLab API uri to consume such as '/projects'
params Object A parameters object such as { 'project_id': 72 }
fillIn Array | requestCallback The Vue.js defined data to fill in with results from GitLab API, or a callback function fed with full response
errorCb errorCallback A callback function in case of error (response is passed to callback)
Source:
Example
// -------------------------------------------------
// 1- With an array to fill in a Vue.js defined data
// -------------------------------------------------
// from anywhere in the global Vue scope
Vue.GitLabAPI.get('/projects', {}, [this.myGitLabData, 'projects'])
// from a .vue component
this.GitLabAPI.get('/projects', {}, [this.myGitLabData, 'projects'])


// ----------------------------------------------------------
// 2- With a callback function to play with the full response
// ----------------------------------------------------------
// from anywhere in the global Vue scope
Vue.GitLabAPI.get('/projects', {}, (response) => {
  console.log('got response:', response)
})
// from a .vue component
this.GitLabAPI.get('/projects', {}, (response) => {
  console.log('got response:', response)
})

(static) post(uri, params, fillIn, errorCb)

Issue a POST request on 'GitLabAPI_url/api/v4' with params and a variable to fill in
Parameters:
Name Type Description
uri String The GitLab API uri to consume such as '/projects'
params Object A parameters object such as { 'project_id': 72 }
fillIn Array | requestCallback The Vue.js defined data to fill in with results from GitLab API, or a callback function fed with full response
errorCb errorCallback A callback function in case of error (response is passed to callback)
Source:
Example
// from anywhere in the global Vue scope
Vue.GitLabAPI.post('/projects/YOUR_PROJECT_ID/issues', {
  title: 'My new issues from vue-gitlab-api'
}, (response) => { console.log('posted it!', response) })

// from a .vue component
this.GitLabAPI.post('/projects/YOUR_PROJECT_ID/issues', {
  title: 'My new issues from vue-gitlab-api'
}, (response) => { console.log('posted it!', response) })

(static) registerStore(store)

Register your application Vuex store to improve it with GitLabAPI Vuex store module
Parameters:
Name Type Description
store Object Your application Vuex store
Source:
Example
// from within a .vue component
this.GitLabAPI.registerStore(this.$store)

(static) setToken(newToken)

Set application wide GitLabAPI token value
Parameters:
Name Type Description
newToken String The new token value
Source:
Example
// from anywhere in the global Vue scope
Vue.GitLabAPI.setToken('your user token')

// from a .vue component
this.GitLabAPI.setToken('your user token')

(static) setUrl(newUrl)

Set application wide GitLabAPI url value
Parameters:
Name Type Description
newUrl String The new GitLab URL value
Source:
Example
// from anywhere in the global Vue scope
Vue.GitLabAPI.setUrl('https://your.gitlab-instance.com')

// from a .vue component
this.GitLabAPI.setUrl('https://your.gitlab-instance.com')