From 295d44d2162f6105c6e9023fb8ba4f347271fba6 Mon Sep 17 00:00:00 2001 From: Angel Caamal Date: Wed, 25 Feb 2026 19:46:45 +0000 Subject: [PATCH 1/2] fix(healthcare): set responseType to JSON instead of Buffer --- healthcare/fhir/searchFhirResourcesPost.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/healthcare/fhir/searchFhirResourcesPost.js b/healthcare/fhir/searchFhirResourcesPost.js index e7756d457f..226599ab4a 100644 --- a/healthcare/fhir/searchFhirResourcesPost.js +++ b/healthcare/fhir/searchFhirResourcesPost.js @@ -45,7 +45,12 @@ const main = ( // specify the following params: // params = {'family:exact' : 'Smith'}; const client = await auth.getClient(); - const response = await client.request({url, method: 'POST', params}); + const response = await client.request({ + url, + method: 'POST', + params, + responseType: 'json', + }); const resources = response.data.entry; console.log(`Resources found: ${resources.length}`); console.log(JSON.stringify(resources, null, 2)); From bd5123c14db3dd55ced4738abb1649be2637d358 Mon Sep 17 00:00:00 2001 From: Angel Caamal Date: Thu, 26 Feb 2026 18:43:50 +0000 Subject: [PATCH 2/2] fix(healthcare): Add error handling to sample --- healthcare/fhir/searchFhirResourcesPost.js | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/healthcare/fhir/searchFhirResourcesPost.js b/healthcare/fhir/searchFhirResourcesPost.js index 226599ab4a..d0fdc774b9 100644 --- a/healthcare/fhir/searchFhirResourcesPost.js +++ b/healthcare/fhir/searchFhirResourcesPost.js @@ -44,16 +44,24 @@ const main = ( // Patient with the last name "Smith", set resourceType to "Patient" and // specify the following params: // params = {'family:exact' : 'Smith'}; - const client = await auth.getClient(); - const response = await client.request({ - url, - method: 'POST', - params, - responseType: 'json', - }); - const resources = response.data.entry; - console.log(`Resources found: ${resources.length}`); - console.log(JSON.stringify(resources, null, 2)); + + try { + const client = await auth.getClient(); + const response = await client.request({ + url, + method: 'POST', + params, + responseType: 'json', + }); + const resources = response.data.entry; + console.log(`Resources found: ${resources.length}`); + console.log(JSON.stringify(resources, null, 2)); + } catch (error) { + console.error( + `Error searching ${resourceType} resources:`, + error.response ? error.response.data : error.message + ); + } }; searchFhirResourcesPost();