We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 50df8bb commit 6d62c49Copy full SHA for 6d62c49
src/lib/harperdb.js
@@ -0,0 +1,25 @@
1
+/**
2
+ * harperClient
3
+ */
4
+
5
+export async function harperClient(body) {
6
+ const requestOptions = {
7
+ method: 'POST',
8
+ headers: {
9
+ 'Content-Type': 'application/json',
10
+ 'Authorization': `Basic ${process.env.HARPER_API_KEY}`,
11
+ },
12
+ body: JSON.stringify(body),
13
+ redirect: 'follow',
14
+ }
15
16
+ const response = await fetch(process.env.HARPER_DATABASE_URL, requestOptions);
17
+ const result = await response.text();
18
19
+ return JSON.parse(result, (key, value) => {
20
+ if ( !isNaN(Date.parse(value)) ) {
21
+ return new Date(value);
22
23
+ return value;
24
+ });
25
+}
0 commit comments