Skip to content

Instantly share code, notes, and snippets.

@franzos
Last active October 26, 2017 08:27
Show Gist options
  • Save franzos/188e6e25a59d99a6bd6d68db92a84d9e to your computer and use it in GitHub Desktop.
Save franzos/188e6e25a59d99a6bd6d68db92a84d9e to your computer and use it in GitHub Desktop.
Pipedrive API and Vue.js 2: Get all persons
<!--
Pipedrive API and Vue.js 2: Get all persons
https://developers.pipedrive.com/docs/api/v1/#!/Persons/get_persons
-->
<script src="https://unpkg.com/vue"></script>
<div id="demo">
<h1>Get all Persons via Pipedrive API using Vue.js</h1>
<form id="search" v-on:submit.prevent>
Enter your Pipedrive API Token <input name="api_token" v-model="api_token">
<button v-on:click="fetchData">Set Token and fetch data</button>
</form>
<ul>
<li v-for="person in persons.data">
<p><strong>{{ person.name }}</strong>
<br>by {{ person.owner_id.name }}</p>
</li>
</ul>
</div>
<script>
var apiURL = 'https://api.pipedrive.com/v1/persons?start=0&api_token='
var demo = new Vue({
el: '#demo',
data: {
persons: [],
name: null,
api_token: null
},
methods: {
fetchData: function () {
var xhr = new XMLHttpRequest()
var self = this
xhr.open('GET', apiURL + self.api_token)
xhr.onload = function () {
self.persons = JSON.parse(xhr.responseText)
}
xhr.send()
}
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment