1.2.4 • Published 11 months ago

@winm2m/web v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@WinM2M/web

This package is a set of features commonly used to build web-based applications. It includes utility functions related to JWT authentication, RESTful API calls to external backend systems, and asynchronous processing. It also includes components to help you handle authentication written in Vue.

Features

  • JWT Authentication: Seamless integration for managing user authentication and token validation.
  • RESTful API Calls: Easy-to-use functions to interact with backend APIs.
  • Asynchronous Handling: Utilities for managing asynchronous operations efficiently.

Installation

To install the package, use npm:

npm install @winm2m/web

Usage Example

import { hasAuthToken, api, setAuthToken } from '@winm2m/web';

if (hasAuthToken()) {
    // Do something
}

api.updateBaseURL('https://example.com');

// request unauthorized
api.post('/api/login', { username: 'admin', password: 'admin' }).then((response) => {
    // Do something
});

// set token. authToken is stored in localStorage
setAuthToken('some token');

// then, request with token
api.get('/api/get-data').then((response) => {
    // Do something
});

// load authToken from localStorage
loadAuthToken();

// to clear authToken
clearAuthToken();

License

This project is licensed under the MIT License.

1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.2.0

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago