wgge 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  export default class HttpHelper {
2
2
 
3
- static async post(url, body) {
3
+ static async processRequest(url, body = null, method = 'GET') {
4
4
  return fetch(url, {
5
- method: 'POST', // *GET, POST, PUT, DELETE, etc.
5
+ method: method,
6
6
  mode: 'cors', // no-cors, *cors, same-origin
7
7
  cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
8
8
  credentials: 'same-origin', // include, *same-origin, omit
@@ -11,10 +11,18 @@ export default class HttpHelper {
11
11
  },
12
12
  redirect: 'follow', // manual, *follow, error
13
13
  referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-uri
14
- body: body // body data type must match "Content-Type" header
14
+ body: body ? JSON.stringify(body) : null // body data type must match "Content-Type" header
15
15
  });
16
16
  }
17
17
 
18
+ static async get(url) {
19
+ return HttpHelper.processRequest(url)
20
+ }
21
+
22
+ static async post(url, body) {
23
+ return HttpHelper.processRequest(url, body, 'POST')
24
+ }
25
+
18
26
  /**
19
27
  *
20
28
  * @param {string} fileName
@@ -129,7 +129,6 @@ export default class EditorController extends ControllerBase {
129
129
  }
130
130
 
131
131
  async saveResources() {
132
- const str = JSON.stringify(this.game.resources.getState());
133
- await HttpHelper.post('http://localhost:88/save-resources', str);
132
+ await HttpHelper.post('http://localhost:88/save-resources', this.game.resources.getState());
134
133
  }
135
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgge",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Web GL Game Engine",
5
5
  "main": "index.js",
6
6
  "dependencies": {