Skip to content

Commit

Permalink
fix(storage-client): get return type
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd authored and njfamirm committed May 18, 2023
1 parent f629f3b commit dfe9728
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/storage-client/src/storage-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,18 @@ export class AlwatrStorageClient<DocumentType extends AlwatrDocumentObject = Alw
async get<T extends DocumentType = DocumentType>(
documentId: string,
storage: string | undefined = this.config.name,
): Promise<T> {
): Promise<T | null> {
this._logger.logMethodArgs?.('get', {storage, documentId});
if (storage == null) throw new Error('storage_not_defined');

const responseJson = await serviceRequest<AlwatrServiceResponseSuccessWithMeta<T>>({
const responseJson = await serviceRequest<AlwatrServiceResponseSuccessWithMeta<T | null>>({
...this.fetchOption,
queryParameters: {
storage,
id: documentId,
},
});

if (typeof responseJson.data !== 'object' || typeof responseJson.data.id !== 'string') {
this._logger.error('get', 'invalid_response_data', {responseJson});
throw new Error('invalid_response_data');
}

return responseJson.data;
}

Expand Down

0 comments on commit dfe9728

Please sign in to comment.