3. Reading / Writing Data
HAT Data
Response type:
interface HatRecord<T> {
endpoint: string; // eg. locations
recordId: string; // A unique record ID of the record.
data: T; // The Data
}Write Data
Parameters
Type
namespace
string
endpoint
string
body
object
Response
HatRecord\
Example:
const namespace = "testhatapp";
const endpoint = "locations";
const newLocation = {
latitude: "51.01",
longitude: "52.12"
};
try {
const result = await hat.hatData().create(
namespace,
endpoint,
newLocation
);
if (result.parsedBody) {
// result.parsedBody contains a HatRecord with the new data.
}
} catch (error) {
// Failed to write data...
}Update Data
Parameters
Type
body
Array>
Response:
Array>
Example:
Delete Data
Parameters
Type
recordIds
Array
Response:
A successful response message
Example:
Read Data
The are 2 ways to fetch data:
With default options.
Parameters
Type
namespace
string
endpoint
string
Response
Array>
Example:
2. With custom options.
Example:
Last updated
Was this helpful?