---
schema_version: "1"
id: 1786d82f6aefea4f38fbf0af9598e5e8a5394bef9d53b82ce336c2a30517ae77
title: FetchUtils | @tableau/taco-toolkit - v2.1.0
collection: tableau
version: next
locale: en-us
portal_url: https://docs.salesforce.com/tableau/next/en-us/api/webdataconnector/reference/classes/handlers.FetchUtils.md
canonical_url: https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html
source_site: help.tableau.com
content_type: documentation
content_hash: 4aca228d36e22478275255a51fab62934cbcc236dfc1afb98a62ff57c4d7fd36
description: Documentation for @tableau/taco-toolkit
---
- [@tableau/taco-toolkit](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/index.html)
- [handlers](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/modules/handlers.html)
- [FetchUtils](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html)

# Class FetchUtils

#### Hierarchy

- FetchUtils

##### Index

### Properties

[fetchArrayBuffer](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html#fetchArrayBuffer) [fetchJson](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html#fetchJson) [ingestDataRows](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html#ingestDataRows) [loadCsvData](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html#loadCsvData) [loadExcelData](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html#loadExcelData) [loadParquetData](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/classes/handlers.FetchUtils.html#loadParquetData)

## Properties

### `Static` fetchArrayBuffer[](#fetchArrayBuffer)

fetchArrayBuffer: ((url, options?) => Promise<Uint8Array\>)

#### Type declaration

- - (url, options?): Promise<Uint8Array\>
    - Fetch binary data from an API endpoint.
        
        The method returns a promise that resolves with an Uint8Array object.
        
        #### Parameters
        
        - ##### url: string
        - ##### `Optional` options: [FetchRequestOptions](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/interfaces/handlers.FetchRequestOptions.html)
        
        #### Returns Promise<Uint8Array\>
        
        #### Example
        
        ```ts
        import { FetchUtils } from '@tableau/taco-toolkit/handlers'const result = await FetchUtils.fetchArrayBuffer('example.com/api/file')// Result: a Uint8Array object which contains the file content
        ```

### `Static` fetchJson[](#fetchJson)

fetchJson: (<D\>(url, options?) => Promise<D\>)

#### Type declaration

- - <D\>(url, options?): Promise<D\>
    - Fetch data from an API endpoint.
        
        The method parses the response body as a JSON string, and returns a promise which resolves with the parsing result.
        
        #### Type Parameters
        
        - #### D = any
        
        #### Parameters
        
        - ##### url: string
        - ##### `Optional` options: [FetchRequestOptions](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/interfaces/handlers.FetchRequestOptions.html)
        
        #### Returns Promise<D\>
        
        #### Example
        
        ```ts
        import { FetchUtils } from '@tableau/taco-toolkit/handlers'const result = await FetchUtils.fetchJson('example.com/api/user', {   method: 'POST',   body: {     id: 'foo',   }})// Result: { id: 'foo', name: 'bar' }
        ```

### `Static` ingestDataRows[](#ingestDataRows)

ingestDataRows: ((rows) => Promise<void\>)

#### Type declaration

- - (rows): Promise<void\>
    - Ingest a list of data with `DataRow` type into EPS data storage. The method returns a promise that resolves when data ingestion succeeds.
        
        The ingested data will be associated with the `handlerInput` that triggers the Fetcher, and uses the `name` property as the table name for the parsed data.
        
        The API must be utilized with built-in file-based parser `taco:data-file-parser` that parses the ingested data from the EPS data storage.
        
        #### Parameters
        
        - ##### rows: [DataRow](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/types/handlers.DataRow.html)\[\]
        
        #### Returns Promise<void\>
        
        #### Example
        
        ```ts
        // handlerInput{   fetcher: 'MyFetcher', // fetcher file name   parser: 'taco:data-file-parser', // built-in data parser name   name: 'user-table' // identifier of source object, it will be used as table name}
        ```
        
        ```ts
        // MyFetcher.tsimport { FetchUtils, DataRow } from '@tableau/taco-toolkit/handlers'export default class MyFetcher extends Fetcher {  async *fetch(options: FetchOptions) {    const users = await FetchUtils.fetchJson('example.com/api/user')    const rows: DataRow[] = users.map((user) => {      const { id, name, address: { street, state, country } } = user      return { id, name, street, state, country }    })    await FetchUtils.ingestDataRows(rows)  }}
        ```

### `Static` loadCsvData[](#loadCsvData)

loadCsvData: ((url, options?) => Promise<void\>)

#### Type declaration

- - (url, options?): Promise<void\>
    - Fetch CSV data from an API endpoint and ingest it into EPS data storage. The function returns a promise that resolves when data ingestion succeeds.
        
        The function is designated for CSV data only. For a data source that provides CSV data in multiple files (with same schema), the function may ingest the files into same table. If the multiple files all contain header line, setting the option `trimColumnHeader` to `true` will let the function skip the header line when ingesting the subsequent files. `trimColumnHeader` has no effect when loading the first file for a table.
        
        Note that loading multiple files into the same table must be performed sequentially, meaning `loadCsvData` must be called after the promise returned from the previous call is resolved.
        
        The API must be utilized with built-in file parser `taco:csv-file-parser` that parses the ingested data from the EPS data storage.
        
        #### Parameters
        
        - ##### url: string
        - ##### `Optional` options: [LoadCsvDataOptions](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/interfaces/handlers.LoadCsvDataOptions.html)
        
        #### Returns Promise<void\>
        
        #### Example
        
        ```ts
        // handlerInput{   fetcher: 'MyFetcher', // fetcher file name   parser: 'taco:csv-file-parser', // built-in csv parser name   name: 'user-table' // identifier of source object, it will be used as table name}
        ```
        
        ```ts
        // MyFetcher.tsimport { FetchUtils } from '@tableau/taco-toolkit/handlers'export default class MyFetcher extends Fetcher {   async *fetch(options: FetchOptions) {     yield await FetchUtils.loadCsvData('example.com/api/user.csv', {       trimColumnHeader: true     })   }}
        ```

### `Static` loadExcelData[](#loadExcelData)

loadExcelData: ((url, options?) => Promise<void\>)

#### Type declaration

- - (url, options?): Promise<void\>
    - Fetch excel data from an API endpoint and ingest it into EPS data storage. The function returns a promise that resolves when data ingestion succeeds.
        
        The function fetches the data in a stream fashion.
        
        The loaded data will be associated with the `handlerInput` that triggers the Fetcher, and the `name` property is used to identify the workbook, while the sheet names will be used as the table names.
        
        The API must be utilized with built-in excel file parser `taco:excel-file-parser` that parses the ingested data from the EPS data storage.
        
        #### Parameters
        
        - ##### url: string
        - ##### `Optional` options: [LoadDataOptions](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/interfaces/handlers.LoadDataOptions.html)
        
        #### Returns Promise<void\>
        
        #### Example
        
        ```ts
        // handlerInput{   fetcher: 'MyFetcher', // fetcher file name   parser: 'taco:excel-file-parser', // built-in parser name   name: 'user-table' // identifier of source object, which will be used to identify the workbook}
        ```
        
        ```ts
        // MyFetcher.tsimport { FetchUtils } from '@tableau/taco-toolkit/handlers'export default class MyFetcher extends Fetcher {   async *fetch(options: FetchOptions) {     yield await FetchUtils.loadExcelData('example.com/api/user.xls')   }}
        ```

### `Static` loadParquetData[](#loadParquetData)

loadParquetData: ((url, options?) => Promise<void\>)

#### Type declaration

- - (url, options?): Promise<void\>
    - Fetch parquet data from an API endpoint and ingest it into EPS data storage. The function returns a promise that resolves when data ingestion succeeds.
        
        The function fetches the data in a stream fashion.
        
        The loaded data will be associated with the `handlerInput` that triggers the Fetcher, and uses the `name` property as the table name for the parsed data fetched from API endpoint/s.
        
        The API must be utilized with built-in parquet file parser `taco:parquet-file-parser` that parses the ingested data from the EPS data storage.
        
        #### Parameters
        
        - ##### url: string
        - ##### `Optional` options: [LoadDataOptions](https://help.tableau.com/v0.0/api/webdataconnector/en-us/reference/interfaces/handlers.LoadDataOptions.html)
        
        #### Returns Promise<void\>
        
        #### Example
        
        ```ts
        // handlerInput{   fetcher: 'MyFetcher', // fetcher file name   parser: 'taco:parquet-file-parser', // built-in parser name   name: 'user-table' // identifier of source object, which will be used as table name}
        ```
        
        ```ts
        // MyFetcher.ts for single API endpointimport { FetchUtils } from '@tableau/taco-toolkit/handlers'export default class MyFetcher extends Fetcher {   async *fetch(options: FetchOptions) {     yield await FetchUtils.loadParquetData('example.com/api/user.parquet')   }}
        ```
        
        Note: The API can also be used to fetch parquet data from multiple API endpoints and append the data together into a single table. The `name` property from the `handlerInput` will be used as the table name for the parsed data fetched from multiple API endpoint.
        
        #### Example
        
        ```ts
        // MyFetcher.ts for multiple API endpointsimport { FetchUtils } from '@tableau/taco-toolkit/handlers'export default class MyFetcher extends Fetcher {   async *fetch(options: FetchOptions) {     const urls = [       'example.com/api/user1.parquet',       'example.com/api/user2.parquet',       'example.com/api/user3.parquet'     ]     const promises = urls.map((url) => FetchUtils.loadParquetData(url))     await Promise.all(promises)     yield   }}
        ```

### Settings

#### Member Visibility

- Inherited

#### Theme

OSLightDark

### On This Page

- [fetchArrayBuffer](#fetchArrayBuffer)
- [fetchJson](#fetchJson)
- [ingestDataRows](#ingestDataRows)
- [loadCsvData](#loadCsvData)
- [loadExcelData](#loadExcelData)
- [loadParquetData](#loadParquetData)

Generated using [TypeDoc](https://typedoc.org/)