3. Reading / Writing Data
HAT Data
interface HatRecord<T> {
endpoint: string; // eg. locations
recordId: string; // A unique record ID of the record.
data: T; // The Data
}Write Data
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
Delete Data
Read Data
Last updated
Was this helpful?