Skip to content

Commit

Permalink
Fix: Provide default metadata for fetching state with pagination (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikowski authored Jun 3, 2024
1 parent e20a811 commit 485d6af
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chaincode/src/utils/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export async function getObjectsByPartialCompositeKeyWithPagination<T extends Ch
results.push(ChainObject.deserialize(constructor, stringResult));
}

const metadata = (await response).metadata;
// Typically, Fabric returns undefined here if there are no results
const metadata: QueryResponseMetadata = (await response).metadata ?? {
bookmark: "",
fetchedRecordsCount: results.length
};

return { results, metadata };
}
Expand Down

0 comments on commit 485d6af

Please sign in to comment.