Skip to content

Instantly share code, notes, and snippets.

@lvreynoso
Created May 20, 2019 19:23
Show Gist options
  • Save lvreynoso/259c79cf0dd0b0b8b255cb11fc8e817b to your computer and use it in GitHub Desktop.
Save lvreynoso/259c79cf0dd0b0b8b255cb11fc8e817b to your computer and use it in GitHub Desktop.
// test our charity navigator api wrapper
app.get('/charities/test', (req, res) => {
let test = {
result: {},
collection: {},
organization: {}
};
test.result.query = modules.charityNavigator.test();
test.collection.query = modules.charityNavigator.collection('10', '1', 'fire')
modules.axios.get(modules.charityNavigator.collection('10', '1', 'fire'))
.then(collection => {
test.collection.response = collection;
test.organization.query = modules.charityNavigator.organization('411867244');
modules.axios.get(modules.charityNavigator.organization('411867244')) // test ein
.then(organization => {
test.organization.response = organization;
res.render('charities-test', {
test: test
})
})
.catch(error => {
console.log(error);
test.organization.response = String(error.response.status + ' ' + error.response.statusText)
res.render('charities-test', {
test: test
})
})
})
.catch(error => {
console.log(error);
res.render('charities-test', {
test: test
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment