PopovMP / dbil

Simple, synchronous and fast document database with MongoDB syntax.
2 stars 0 forks source link

Error parsing req.body parameter when using as express module #1

Open fsi2000 opened 3 months ago

fsi2000 commented 3 months ago

Get error "[ERROR] [db-api :: dbAction] cannot parse parameter: query" when using as express module. argText is already of type object - this causes JSON.parse to return an error.

Quick-fix in ./node_modules/@popovmp/dbil/lib/api.js

      let argObj = null;
      const argText = req.body[param] || "{}";
      if (typeof argText === "object") {
        argObj = argText;
      } else {
        argObj = JSON.parse(argText);
      }
PopovMP commented 3 months ago

Thank you for the report!

The issue is fixed in v4.8.1