Registry / devops / sanji-rest-ui

sanji-rest-ui

JSON →
library1.5.0jsnpmunverified

An AngularJS (1.x) RESTful service wrapper for the Sanji IoT framework. Version 1.5.0 is the latest stable release, last updated around 2017 and currently in maintenance mode. It provides a simple HTTP/WebSocket abstraction for REST API calls, supporting common methods like get, post, put, delete, etc. Key differentiators include protocol switching (default HTTP, can switch to WebSocket) and integration with ng-file-upload. Dependencies: Angular >=1.4 <1.7 and ng-file-upload ^12.2.13.

npm install sanji-rest-ui
INSTALL
IMPORT
SIG · SANJI-REST-UI
S
sanji-rest-ui
devopsjavascriptv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sanji.rest module
angular.module('app', ['sanji.rest'])
import { rest } from 'sanji-rest-ui'
Register the module with AngularJS; the rest service is injected via DI.
rest service
constructor(rest) { ... } \nAppController.$inject = ['rest'];
const rest = require('sanji-rest-ui')
The 'rest' service is injected into AngularJS controllers/directives as a dependency.
rest methods
rest.get('/api/users').then(...)
rest.get('/api/users').success(...)
Uses promise .then/.catch, not Angular's deprecated .success/.error.

Shows how to install, include the sanji.rest module, and use the rest service for GET and POST requests with error handling.

// Install: npm install sanji-rest-ui --save // Include the module in your AngularJS app let app = angular.module('webapp', ['sanji.rest']); // Use the rest service class AppController { constructor(rest) { rest.get('/users/me') .then(data => console.log(data)) .catch(error => console.error(error)); rest.post('/login', { username: 'admin', password: process.env.PASSWORD ?? '' }) .then(data => console.log('Logged in', data)) .catch(error => console.error('Login failed', error)); } } AppController.$inject = ['rest']; // Bootstrap AngularJS (assuming html has ng-app) angular.bootstrap(document, ['webapp']);
Debug
Known issues
breakingRequires AngularJS 1.x (>=1.4 <1.7). Incompatible with Angular 2+.
fix
Use AngularJS 1.x or migrate to a different HTTP service for Angular 2+.
affects: >=1.0
breakingModule name changed: must use 'sanji.rest' (with a dot) instead of 'sanjiRest' or other variations.
fix
Use 'sanji.rest' when defining angular module dependencies.
affects: >=1.0
deprecatedPromises use .then/.catch, but some older examples may show .success/.error which are deprecated in AngularJS.
fix
Always use .then/.catch for promise handling.
affects: >=1.0
gotchaThe rest service may not work without the Sanji backend; it expects specific API patterns.
fix
Ensure your backend conforms to Sanji REST conventions or develop a custom adapter.
affects: >=1.0
Errors
Common errors & fixes
Module 'sanji.rest' is not available! You either misspelled the module name or forgot to load it.
The module 'sanji.rest' was not imported or registered before AngularJS bootstrap.
fix
Ensure you have 'import' or 'require' the sanji-rest-ui package before defining your angular module: run 'npm install sanji-rest-ui' and include the script or bundle.
Error: $injector:modulerr Failed to instantiate module webapp due to: Error: [$injector:modulerr] Failed to instantiate module sanji.rest due to: Error: [$injector:nomod] Module 'sanji.rest' is not available!
The script file for sanji-rest-ui is not loaded in the HTML or not included in the bundle.
fix
Add the script tag for sanji-rest-ui (e.g., <script src="node_modules/sanji-rest-ui/dist/sanji-rest-ui.js"></script>) or configure your module bundler to include it.
Cannot read property 'get' of undefined
The 'rest' service is not injected properly into the controller.
fix
Add '$inject' annotation as shown: AppController.$inject = ['rest']; and ensure the module 'sanji.rest' is included in the app.
Upgrade
Version history
1.5.0latest on npm
Audit
Dependencies
angularrequiredAngularJS 1.x framework required
ng-file-uploadoptionalFile upload support
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
sanji-rest-ui — npm install sanji-rest-ui · libregistry