From fd57221ea8aa320b03ba36dbafdcc3b17fa6d0e9 Mon Sep 17 00:00:00 2001
From: Javier Segarra <jsegarra@verdnatura.es>
Date: Tue, 8 Apr 2025 14:44:34 +0200
Subject: [PATCH] feat: fetch modelInfo

---
 lib/salix.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/salix.js b/lib/salix.js
index 9f2e40f..db28c25 100644
--- a/lib/salix.js
+++ b/lib/salix.js
@@ -142,11 +142,12 @@ module.exports = class Salix {
         `${this.conf.salix.url}/${path}`,
         fetchConfig
       );
-      if (salixCall.status !== 200) {
-        throw new Error(response);
-      }
       const responseText = await salixCall.text();
       const response = JSON.parse(responseText);
+      
+      if (salixCall.status !== 200) {
+         throw new Error(response.error.message);
+      }
 
       const newVersion = salixCall.headers.get(SALIX_VERSION_HEADER);
       if (!this.salixVersion) {
@@ -172,14 +173,13 @@ module.exports = class Salix {
   async getSalixVersion() {
     this.log("CHECK VERSION");
 
-    await this.fetch(this.conf.salix.api.status);
+    await this.fetch(this.conf.salix.api.modelinfo);
 
-    this.log("VERSION CHECKED");
+    this.log("VERSION CHECKED -- "+ this.salixVersion);
   }
 
   async salixLogInfo() {
     this.log("REQUEST LOGINFO");
-    await this.getToken();
     let salixLogConfig = await this.fetch(this.conf.salix.api.logInfo);
 
     this._logInfo = salixLogConfig;