Utilities for supporting the making http requests

Usage no npm install needed!

<script type="module">
  import kobotechCoreHttp from 'https://cdn.skypack.dev/@kobotech/core-http';


Kobo360 Core Http Library

This library provides utilities for handing http requests and responses.


Add the dependency to this library in your project's package.json in the dependencies section;

  "dependencies": {
    "@kobotech/core-http": "1.0.0"

Run npm install to install the defined dependencies;

To use the library in your project.

const coreHttp = require("@kobotech/core-http");

Respond with an error message

const data = "content";
const errorMessage = "error";
const httpStatus = 401;
coreHttp.sendErrorJsonResponse(response, data, errorMessage, httpStatus);

this call will write on the response object a json payload as seen below;

{ "success": false, "message": error, "data": "content" }

The data could be any type, whether string or array or even an object as long as it's supported by json.