@wkcz/praetor-sdk
v1.9.16
Published
Praetor Web SDK
Downloads
71
Keywords
Readme
Praetor SDK
This package provides the Praetor SDK, a custom interface and implementation for interacting with Praetor.
Prerequisites
Make sure you have Node.js
and npm
installed on your machine.
See Installing Node.js and npm for detailed instructions.
Installation
To use the Praetor SDK in your project, install it via npm
.
Open a terminal and run the following command:
npm install @wkcz/praetor-sdk
Importing the package
TypeScript
import { Praetor } from "@wkcz/praetor-sdk";
JavaScript
const { Praetor } = require("@wkcz/praetor-sdk");
Examples
fetch(callName)
// GET request
const praetor = new Praetor();
const response = await praetor.fetch("someCallName");
fetch(callName, options)
// POST request
const praetor = new Praetor();
const response = await praetor.fetch("someCallName", { method: "POST", body: JSON.stringify({ someData: 200 }) });
fetch(callName).json()
fetch(callName, options).json()
// Bad
const praetor = new Praetor();
const response = await praetor.fetch("someCallName");
const data = JSON.parse(response.body);
// Good
const praetor = new Praetor();
const response = await praetor.fetch("someCallName");
const data = await response.json();
// Bad
const praetor = new Praetor();
const data = await praetor.fetch("someCallName").then(response => JSON.parse(response.body));
// Good
const praetor = new Praetor();
const data = await praetor.fetch("someCallName").then(response => response.json());
fetch(callName).blob()
fetch(callName, options).blob()
const praetor = new Praetor();
const response = await praetor.fetch("someCallName");
const data = await response.blob();
const praetor = new Praetor();
const data = await praetor.fetch("someCallName").then(response => response.blob());
devMode()
const praetor = new Praetor();
const devMode = await praetor.devMode();
api.selectPerson()
const praetor = new Praetor();
const person = await praetor.api.selectPerson();