From 516117a09368593b3dd884183a24e4ba2983bae5 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Tue, 3 Jan 2023 10:47:05 +0100 Subject: [PATCH] Remove usage of read in favour of readUrl Signed-off-by: Johan Haals --- .../features/software-catalog/external-integrations.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/features/software-catalog/external-integrations.md b/docs/features/software-catalog/external-integrations.md index 66813cc4d2..da4eb3d229 100644 --- a/docs/features/software-catalog/external-integrations.md +++ b/docs/features/software-catalog/external-integrations.md @@ -111,10 +111,10 @@ export class FrobsProvider implements EntityProvider { throw new Error('Not initialized'); } - const raw = await this.reader.read( + const response = await this.reader.readUrl( `https://frobs-${this.env}.example.com/data`, ); - const data = JSON.parse(raw.toString()); + const data = JSON.parse(await response.buffer()).toString(); /** [5] **/ const entities: Entity[] = frobsToEntities(data); @@ -525,8 +525,8 @@ export class SystemXReaderProcessor implements CatalogProcessor { // API. If you prefer, you can just use plain fetch here // (from the node-fetch package), or any other method of // your choosing. - const data = await this.reader.read(location.target); - const json = JSON.parse(data.toString()); + const response = await this.reader.readUrl(location.target); + const json = JSON.parse((await response.buffer()).toString()); // Repeatedly call emit(processingResult.entity(location, )) } catch (error) { const message = `Unable to read ${location.type}, ${error}`; @@ -627,7 +627,7 @@ export class SystemXReaderProcessor implements CatalogProcessor { // We send the ETag from the previous run if it exists. // The previous ETag will be set in the headers for the outgoing request and system-x // is going to throw NOT_MODIFIED (HTTP 304) if the ETag matches. - const response = await this.reader.readUrl?.(location.target, { + const response = await this.reader.readUrl(location.target, { etag: cacheItem?.etag, }); if (!response) {