Question

Problem with custom app to connect with pipedrive

  • 1 March 2021
  • 1 reply
  • 14 views

We are developing an app to connect pipedrive with Freshdesk, but I am stuck with this problem: Cannot set property 'apiToken' of undefined.

Note. This is the server.js code that is running locally at server side

 

const pipedrive = require("pipedrive")  

exports = {
getNote: async function (payload) {
try {
pipedrive.Configuration.apiToken = "XXXXXXXXXXXX"
var Personctrl = pipedrive.PersonsController
var Notasctrl = pipedrive.NotesController
const searchPerson = await Personctrl.findPersonsByName({
term: payload.email,
searchByEmail: 1
})

if (searchPerson.data && searchPerson.data.length > 0) {
for (const result of searchPerson.data) {
console.log(`${result.name} (id: ${result.id})`)

const searchResults = await Notasctrl.getAllNotes({
person_id: result.id
})

if (searchResults.data && searchResults.data.length > 0) {
const myJSON = JSON.stringify(searchResults.data)

renderData(null, myJSON)
} else {
console.log("No notes found")
}
}
} else {
console.log("No user found")
renderData(null)
}
} catch (error) {
console.log(error)

renderData(error)
}
}
}

 


1 reply

Note: Using https://npm.runkit.com/ the code works…. could it be something with the fdk? 

I am using pipedrive@10.4.3, node v10.18.0, nvm 0.37.2 and fdk 6.9.7

Reply