Skip to content

Commit

Permalink
fix handling the API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-tavares committed Dec 9, 2020
1 parent 65d3835 commit e5f7a64
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,23 @@ export const EditPackagePolicyForm = memo<{
setIsLoadingData(true);
setLoadingError(undefined);
try {
const { data: packagePolicyData } = await sendGetOnePackagePolicy(packagePolicyId);
const {
data: packagePolicyData,
error: packagePolicyError,
} = await sendGetOnePackagePolicy(packagePolicyId);

if (!packagePolicyData?.item.policy_id) {
throw new window.Error(`Agent Policy ID missing in package policy ${packagePolicyId}`);
if (packagePolicyError) {
throw packagePolicyError;
}

const { data: agentPolicyData } = await sendGetOneAgentPolicy(
packagePolicyData.item.policy_id
const { data: agentPolicyData, error: agentPolicyError } = await sendGetOneAgentPolicy(
packagePolicyData!.item.policy_id
);

if (agentPolicyError) {
throw agentPolicyError;
}

if (agentPolicyData?.item) {
setAgentPolicy(agentPolicyData.item);
}
Expand Down

0 comments on commit e5f7a64

Please sign in to comment.