Skip to content

Functions:parseData

Thomas Timmer edited this page Jun 26, 2023 · 2 revisions

The parseData helper makes it easier to parse different datatypes in an Action. The function takes in an object with keys; data and format, and returns a Promise with a list objects. The data keys can be one of these: a string with the data or a url pointing to the data.

typeJSONValue=string|number|boolean|null|JSONObject|JSONArray;interfaceJSONObject{[x: string]: JSONValue;}typeJSONArray=Array<JSONValue>;typeFormat='CSV'|'JSON';interfaceParseDataArguments{data: string;format?: Format;}asyncfunctionparseData({
data,
format,}: ParseDataArguments): Promise<JSONValue[]>;

Examples

constdata=`[ {"data": 1, "description": ""}, {"data": 2, "description": ""}]`;awaitparseData({
data,format: 'JSON',});
constdata=`order_id;customer;paid;created_at14987576452870392979;John Doe;true;2213-05-22T16:08:55.067342584Z638002794201564283;Jane Doe;true;2149-05-03T23:22:31.389391892Z`;awaitparseData({
data,format: 'CSV',});
consturl='https://httpbin.org/json';awaitparseData({
url,format: 'JSON',});

Clone this wiki locally