diff --git a/src/index.d.ts b/src/index.d.ts index 0a80e14..e02c484 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -49,7 +49,8 @@ export class WireKVSDatabase extends EventEmitter { disconnect(): void; getAllEntries(): Promise; - get(key: string): Promise; + get(key: string): Promise; + json(key: string): Promise; set(key: string, value: any): Promise; update(key: string, value: any): Promise; delete(key: string): Promise; diff --git a/src/index.js b/src/index.js index 204d0b6..c837e9b 100644 --- a/src/index.js +++ b/src/index.js @@ -130,6 +130,16 @@ class WireKVSDatabase extends EventEmitter { return response.data; } + async json(key) { + const response = await axios.get( + `${API_BASE_URL}/database/${this.id}/${key}`, + { + headers: { Authorization: this.accessKey }, + } + ); + return JSON.parse(response.data); + } + async set(key, value) { await axios.post(`${API_BASE_URL}/database/${this.id}/${key}`, value, { headers: { Authorization: this.accessKey },