REST Service for POPCORN - ILIAS
alex
2025-06-20 e2dc64672428e599d45c70c6c560e06501477e0b
lib/libIlias.js
@@ -1,4 +1,5 @@
/* Lib for interacting with customized ILIAS php */
const _ = require("lodash")
const settings = require("../settings")
const {getObjIdFromRefId} = require("./db")
const db = require("./db")
@@ -58,30 +59,24 @@
      token: iliastoken,
   })
   let url2 = `${url}?${sp.toString()}`
   console.log(url2)
   const udfDef = await db.getUdf()
   const udfMap = _.keyBy(udfDef, "field_name")
   user.udf = _.mapKeys(user.udf, function (value, key) {
      return udfMap[key].field_id
   })
   const res = await fetch(url2, {
      method: "POST",
      body: JSON.stringify(user)
   })
   // const data = await res.json()
   // return data
   const text = await res.text()
   try {
      const json = JSON.parse(text)
      return json
      return JSON.parse(text)
   } catch (ex) {
      console.error(ex.message)
      console.log(text)
      throw ex
   }
   try {
      return data
   } catch (ex) {
      const text = await res.text()
      console.error(text)
      return false
   }
}