moahmedwafy commited on
Commit
15e7f40
·
unverified ·
2 Parent(s): cdfcb96 ae604b6

Merge pull request #102 from Modarb-Ai-Trainer/fix-models

Browse files
src/lib/models/fitness-model.ts CHANGED
@@ -1,3 +1,4 @@
 
1
  import { FitnessGoal } from "@common/enums/fitness-goal.enum";
2
  import { FitnessLevel } from "@common/enums/fitness-level.enum";
3
  import { Gender } from "@common/enums/gender.enum";
@@ -52,8 +53,9 @@ export class FitnessModel {
52
  throw new Error("Failed to fetch data from the server");
53
  }
54
 
55
- return response.json().then((data) => {
56
- return data.result;
 
57
  });
58
  }
59
  }
 
1
+ import { ExerciseType } from "@common/enums/exercise-type.enum";
2
  import { FitnessGoal } from "@common/enums/fitness-goal.enum";
3
  import { FitnessLevel } from "@common/enums/fitness-level.enum";
4
  import { Gender } from "@common/enums/gender.enum";
 
53
  throw new Error("Failed to fetch data from the server");
54
  }
55
 
56
+ return response.text().then((data) => {
57
+ data = data.replace('NaN', ExerciseType.DURATION.toString()).replace('\n', '')
58
+ return JSON.parse(data)
59
  });
60
  }
61
  }
src/lib/models/nutrition_model.ts CHANGED
@@ -39,8 +39,8 @@ export class NutritionModel {
39
  throw new Error("Failed to fetch data from the server");
40
  }
41
 
42
- return response.json().then((data) => {
43
- return data.result as INutritionPredictionItem[][];
44
  });
45
  }
46
  }
 
39
  throw new Error("Failed to fetch data from the server");
40
  }
41
 
42
+ return response.text().then((data) => {
43
+ return JSON.parse(data) as INutritionPredictionItem[][];
44
  });
45
  }
46
  }