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 1d0fb18 commit 699cba3Copy full SHA for 699cba3
lib/fslib.browser.js
@@ -28,7 +28,22 @@ function readDB(path)
28
29
function writeDB(path, jsonStr)
30
{
31
- return Promise.reject(new UnsupportedInBrowserError('writeDB()'));
+ return fetch(path, {
32
+ method: 'POST',
33
+ mode: 'cors',
34
+ headers: { 'Content-Type': 'application/json' },
35
+ body: jsonStr
36
+ })
37
+ .then((data) => data.json())
38
+ .catch((err) =>
39
+ {
40
+ const error = new Error(`Failed to post to '${ path }'.`);
41
+ error.innerException = err;
42
+ error.code = 'ERR_POST';
43
+
44
+ console.error(err);
45
+ throw error;
46
+ });
47
} // end writeDB
48
49
//----------------------------------------------------------------------------------------------------------------------
0 commit comments