Skip to content

VaultApiClient

Provides functions to use Vault API from client code.

fetch: (input, init?) => Promise<Response>

Makes authorized requests to Vault API and prepends the /api prefix to the path. This is a wrapped version of JavaScript's fetch function.

string

A URL string to make a request to

RequestInit

A RequestInit object containing any custom settings that you want to apply to the request

Promise<Response>

A Promise which is fulfilled with a Response object representing the server's response

Only accepts strings as input, not URL or Request objects.

Naively prepends /api to the provided URL. For example, calling this with "http://example.com" would make a request to "/api/http://example.com".

import { vaultApiClient } from '@veeva/vault'

const response = await vaultApiClient.fetch(
      '/v25.1/objects/documents/301',
      {
        headers: {
          Accept: 'application/json',
        },
      }
    );
const json = response.json();