Skip to content

Instantly share code, notes, and snippets.

@sshadmand
Created July 21, 2017 16:01
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 sshadmand/3382212cca8e65a0a96c4bdb2eb450f7 to your computer and use it in GitHub Desktop.
Save sshadmand/3382212cca8e65a0a96c4bdb2eb450f7 to your computer and use it in GitHub Desktop.
Pitchbook API with JS and JQuery
const BASE_URL = "https://api.pitchbook.com"
const TOKEN = "TOKEN HERE"
$.ajaxSetup({
headers: { 'authorization': TOKEN }
});
const generalSearch = function(name) {
var def = jQuery.Deferred();
$.getJSON( BASE_URL + '/search?name=' + name, function( response ) {
def.resolve(response.results.results);
});
return def.promise();
}
const getCompanyProfile = function(companyID) {
var def = jQuery.Deferred();
$.getJSON( BASE_URL + '/companies/' + companyID['companyId'] + '/details', function( response ) {
// def.resolve(response);
console.log(response)
});
return def.promise();
}
const companySearch = function(keywords) {
var def = jQuery.Deferred();
$.getJSON( BASE_URL + '/companies/search?keywords=' + keywords, function( response ) {
const companyIDs = response.results.items;
companyIDs.forEach(function(companyObj, index){
getCompanyProfile(companyObj).then(function(companyProfile){
// console.log(companyProfile)
});
});
});
return def.promise();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment