@labeg/tfetch 0.5.0 → 0.6.0

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.
@@ -93,7 +93,12 @@ export class TsFetch {
93
93
  else if (Array.isArray(returnType) &&
94
94
  responseText.startsWith("[")) {
95
95
  data = JSON.parse(responseText);
96
- // Return models.map((model: object) => new returnType[0]().fromJSON(model));
96
+ if ( // If its Serializable class
97
+ typeof returnType[0] === "function" &&
98
+ returnType[0].prototype instanceof Serializable) {
99
+ const constructor = returnType[0];
100
+ data = data.map((model) => new constructor().fromJSON(model));
101
+ }
97
102
  }
98
103
  else if (typeof returnType === "function" &&
99
104
  returnType.prototype instanceof Serializable &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labeg/tfetch",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "author": "Eugene Labutin",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/LabEG/ts-fetch#readme",