GET
/
csv
Example Usage
/**
   * Converts a CSV file to JSON.
   *
   * @param file The CSV file to convert.
   * @returns A promise that resolves to the JSON data.
   * @throws Error if the file cannot be converted.
   */
  const csvToJson = async (file: File): Promise<any> => {
    try {
      const formData = new FormData()
      formData.append('file', file)

      const initialResponse = await axiosInstance.post<any>(`/csv`, formData, {
        headers: {
          'Content-Type': 'multipart/form-data',
        },
      })

      if (initialResponse.status === 'SUCCESS') {
        return initialResponse.data
      }

      let exit = false
      let data: any[] = []

      while (!exit) {
        await new Promise((resolve) => setTimeout(resolve, 2000))
        const pollResponse = await axiosInstance.get<any>(`/csv/${initialResponse.id}`, {
          headers: {
            'Content-Type': 'application/json',
          },
        })

        if (pollResponse.status === 'SUCCESS') {
          data = pollResponse.data
          exit = true
        }
      }

      return data
    } catch (error) {
      console.error('Error handling the CSV file:', error)
      throw error
    }
  }

Authorizations

Authorization
string
headerrequired

The access token received from the authorization server in the OAuth 2.0 flow.

Query Parameters

page
integer
default: 1

Page number

size
integer
default: 50

Page size

Response

200 - application/json
items
object[]
required
total
integer | null
required
page
integer | null
required
size
integer | null
required
pages
integer | null