CSV to JSON
Get CSVs
Get a list of all CSV extraction tasks.
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
headerrequiredThe access token received from the authorization server in the OAuth 2.0 flow.
Query Parameters
page
integer
default: 1Page number
size
integer
default: 50Page size
Response
200 - application/json
items
object[]
requiredtotal
integer | null
requiredpage
integer | null
requiredsize
integer | null
requiredpages
integer | null