Skip to content
Snippets Groups Projects
Verified Commit 3d244470 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: add raw data to restapi respond

parent 434a6b80
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,16 @@ import { WriteError } from "./restapi/writeerror.mjs"; ...@@ -12,6 +12,16 @@ import { WriteError } from "./restapi/writeerror.mjs";
export { RestAPI }; export { RestAPI };
/**
* @type {symbol}
* @memberOf Monster
* @license AGPLv3
* @since 3.12.0
*/
const rawDataSymbol = Symbol.for("@schukai/monster/data/datasource/server/restapi/rawdata");
/** /**
* The RestAPI is a class that enables a REST API server. * The RestAPI is a class that enables a REST API server.
* *
...@@ -182,6 +192,9 @@ function fetchData(init, key, callback) { ...@@ -182,6 +192,9 @@ function fetchData(init, key, callback) {
try { try {
obj = JSON.parse(body); obj = JSON.parse(body);
response[rawDataSymbol] = obj;
} catch (e) { } catch (e) {
if (body.length > 100) { if (body.length > 100) {
body = `${body.substring(0, 97)}...`; body = `${body.substring(0, 97)}...`;
...@@ -193,6 +206,7 @@ function fetchData(init, key, callback) { ...@@ -193,6 +206,7 @@ function fetchData(init, key, callback) {
if (callback && isFunction(callback)) { if (callback && isFunction(callback)) {
callback(obj); callback(obj);
} }
return response; return response;
}); });
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment