npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mobile-simple-rest-call

v0.0.7

Published

A simpler way to call HTTP REST endpoints from a mobile Cordova application.

Downloads

16

Readme

mobile-simple-rest-call

A simple API to speed up mobile Cordova development. The goal is to provide a stable and simple API to call HTTP REST endpoints and implement local caching according to HTTP server's response (as implemented by web browsers). The library will take care of caching the server's response when required, avoiding unnecessary trafic and data plan costs apart from speeding up the App.

It uses the best supported database for Cordova, which runs on Android, iOS and Windows platforms (see Cordova Storage documentation for further details).

Sonarcloud-QualityGate Sonarcloud-Security Sonarcloud-Quality Sonarcloud-Reliability Sonarcloud-Vulnerability

License

License: GPL v3 This work is Licensed under GPL v3. You can copy, modify and distribute this software even for commercial purposes; however you must include the reference to the original author and if you modify this software, you must re-distribute it using the same permissive License.

Features

The advantage of this library is having the same behavior across the supoprted platforms and the use of SQLite database. I was motivated to develop this lib due to the inconsistent behavior when communicating with one of our customer's backend as the cache was triggered sometimes in one platform and not in another and the quirks when saving simple key/value data on local database.

Simple REST operations

The library supports common HTTP operations for the purpose of mobile development. The most common errors (e.g. timeout, server error) are already handled; you just need to implement the callbacks where applicable.

HTTP operations:

  • GET
  • POST
  • PUT
  • DELETE

Local key/value and cache database

Implemented using SQLite database, supported on iOS, Android and Windows platforms.

For GET operations, the library will take care of caching the server response when needed, avoiding unnecessary network traffic and calls to backend processing routines and extra data usage.

First steps

Start a new Cordova project

Install Cordova (https://cordova.apache.org/docs/en/latest/guide/cli/#installing-the-cordova-cli). It depends on NodeJS and NPM.

To start a new Cordova project, execute (see https://cordova.apache.org/#getstarted):

cordova create MyApp

cd MyApp

cordova platform add <platform name e.g. ios, android>

Get this library and its dependencies

npm install mobile-simple-rest-call --save

Then copy node_modules/mobile-simple-rest-call/dist/cordova-simplerestcall.min.js and node_modules/jquery/dist/jquery.min.js to your newly created project under www/js directory.

Using this library

You'll need to import the required libraries on your index.html file and initialize the database:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:; script-src * data: https://ssl.gstatic.com 'unsafe-inline' 'unsafe-eval';">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/jquery.min.js"></script> <!-- here... -->
        <script type="text/javascript" src="js/cordova-simplerestcall.min.js"></script> <!-- ...and here -->
        <script type="text/javascript">
            // Initializing the database for local caching and parameters
            dbmgr.init();
        </script>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>

IMPORTANT NOTE: as this library is still being developed, the build is broken right now; I plan to fix the minified file in a couple of days.

To call a REST GET endpoint, you'll need just to call wscall.get(...):

wscall.get(
    'http://myserver.org/users/1234',
    // (Optional) query strings
    null,
    function(responseData) {
        // Do something when the response is successful
    },
    function(error) {
        // Do something when an error happens
    }
);

Similarly, to call a REST POST endpoint you'd invoke:

wscall.post(
    'http://myserver.org/users',
    // Data to be sent
    {
        "some_data": {
            "foo": "bar",
            "baz": 0.0,
            "nil": null
        }
    },
    function(responseData) {
        // Do something when the response is successful
    },
    function(error) {
        // Do something when an error happens
    }
);

The same applies to PUT and DELETEoperations:

wscall.put(
    'http://myserver.org/users/1234',
    // Data to be updated
    {
        "some_data": {
            "foo": "bar",
            "baz": 0.0,
            "nil": null
        }
    },
    function(responseData) {
        // Do something when the response is successful
    },
    function(error) {
        // Do something when an error happens
    }
);
wscall.delete(
    'http://myserver.org/users/1234',
    // (Optional) query strings
    null,
    function(responseData) {
        // Do something when the response is successful
    },
    function(error) {
        // Do something when an error happens
    }
);

Contributions

Contributions are welcome! If you find a bug, or want to suggest an improvement please send me an email at opensource (at) glauber.me. You can also fill a bug report on Github and I'll work on it on my free time.

Donation

Donate You can pay me a coffee (:coffee:) or a beer (:beers:) :) I'll be more than happy with your contribution as humble as it is.