From d4c5780444f371f6afbce869a79d9dcc453601be Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Mon, 20 May 2019 13:23:32 -0500 Subject: [PATCH] Fix bug where lack of user confirmation causes some bugs to occur --- .../get_campaign_and_event_names_and_ids.js | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/client/js/common/ajax/get_campaign_and_event_names_and_ids.js b/client/js/common/ajax/get_campaign_and_event_names_and_ids.js index be8b833e..842d53ba 100644 --- a/client/js/common/ajax/get_campaign_and_event_names_and_ids.js +++ b/client/js/common/ajax/get_campaign_and_event_names_and_ids.js @@ -6,21 +6,31 @@ module.exports = function(npo_id) { var eventsPath = '/nonprofits/' + npo_id + '/events/name_and_id' request.get(campaignsPath).end(function(err, resp){ - resp.body.unshift(false) - let campaign_id_names = resp.body.map((i) => { - if (i.isChildCampaign) - { - return {id: i.id, name: i.name + " - " + i.creator} - } - else - { - return {id: i.id, name: i.name} - } - }) - appl.def('campaigns.data', campaign_id_names) + var dataResponse = [] + + if (!err) { + resp.body.unshift(false) + dataResponse = resp.body.map((i) => { + if (i.isChildCampaign) + { + return {id: i.id, name: i.name + " - " + i.creator} + } + else + { + return {id: i.id, name: i.name} + } + }) + } + appl.def('campaigns.data', dataResponse) }) + request.get(eventsPath).end(function(err, resp){ - resp.body.unshift(false) - appl.def('events.data', resp.body) + var dataResponse = [] + if(!err) { + resp.body.unshift(false) + dataResponse = resp.body + } + + appl.def('events.data', dataResponse) }) }