smart-on-fhir / client-js

JavaScript client for FHIR
Other
292 stars 209 forks source link

Allow for setting Custom URL instead of deducing from ResourceType #188

Closed EniacMlezi closed 1 month ago

EniacMlezi commented 1 month ago

Is your feature request related to a problem? Please describe. I'm trying to 'Create' a Bundle using a transaction.

{
  resourceType: 'Bundle',
  type: 'transaction',
  entry: [
    {
      resource: someResource,
      request: {
        method: 'POST',
        url: someResource.resourceType,
      },
    },
  ],
}

A transaction should be posted to the [BASE] Url, as described here. However, the request gets posted to [BASE]/Bundle.

Describe the solution you'd like Adding an optional parameter to all crud methods, or an extension of the fetchOptions to allow for setting a custom URL.

EniacMlezi commented 1 month ago

Just figured out you can also just do:

client.request({
      url: '/',
      method: 'POST',
      body: JSON.stringify(yourBundle),
    });