Skip to content

Commit f9b8d86

Browse files
authored
fix(healthcare): set responseType to JSON in getFhirResource.js (#4228)
* fix(healthcare): set responseType to JSON instead of Buffer * fix(healthcare): Add error handling to sample
1 parent 33a2273 commit f9b8d86

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

healthcare/fhir/getFhirResource.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const main = (
2929
auth: new google.auth.GoogleAuth({
3030
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
3131
}),
32+
responseType: 'json',
3233
});
3334

3435
const getFhirResource = async () => {
@@ -42,11 +43,18 @@ const main = (
4243
const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/${resourceType}/${resourceId}`;
4344
const request = {name};
4445

45-
const resource =
46-
await healthcare.projects.locations.datasets.fhirStores.fhir.read(
47-
request
46+
try {
47+
const resource =
48+
await healthcare.projects.locations.datasets.fhirStores.fhir.read(
49+
request
50+
);
51+
console.log(`Got ${resourceType} resource:\n`, resource.data);
52+
} catch (error) {
53+
console.error(
54+
`Error getting ${resourceType} resource:`,
55+
error.message || error
4856
);
49-
console.log(`Got ${resourceType} resource:\n`, resource.data);
57+
}
5058
};
5159

5260
getFhirResource();

0 commit comments

Comments
 (0)