Skip to content

Commit 33a2273

Browse files
angelcaamaliennae
andauthored
fix(healthcare): set responseType to JSON instead of Buffer in updateFhirResource.js (#4232)
* fix(healthcare): set responseType to JSON instead of Buffer * fix(healthcare): Add error handling to sample --------- Co-authored-by: Jennifer Davis <sigje@google.com>
1 parent a367721 commit 33a2273

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

healthcare/fhir/updateFhirResource.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const main = (
3030
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
3131
}),
3232
headers: {'Content-Type': 'application/fhir+json'},
33+
responseType: 'json',
3334
});
3435

3536
const updateFhirResource = async () => {
@@ -47,11 +48,18 @@ const main = (
4748
const body = {resourceType: resourceType, id: resourceId, active: true};
4849
const request = {name, requestBody: body};
4950

50-
const resource =
51-
await healthcare.projects.locations.datasets.fhirStores.fhir.update(
52-
request
51+
try {
52+
const resource =
53+
await healthcare.projects.locations.datasets.fhirStores.fhir.update(
54+
request
55+
);
56+
console.log(`Updated ${resourceType} resource:\n`, resource.data);
57+
} catch (error) {
58+
console.error(
59+
`Error updating ${resourceType} resource:`,
60+
error.message || error
5361
);
54-
console.log(`Updated ${resourceType} resource:\n`, resource.data);
62+
}
5563
};
5664

5765
updateFhirResource();

0 commit comments

Comments
 (0)