0.0.22 • Published 4 years ago

feather-client-js v0.0.22

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Feather Client Javascript Library

npm

This library provides a convenient stateful interface to the Feather API for applications running in a Javascript client environment.

Have any questions? We're hanging out on Discord 👋

Install

$ npm install feather-client-js --save
# or
$ yarn add feather-client-js

Usage

The Feather package must be initialized with your project's API key, available on the Feather Dashboard. Include the API key when you require the package:

import { FeatherClient } from "feather-client-js";

const feather = FeatherClient("YOUR_API_KEY");

To listen for changes to the authentication state:

const unsubscribe = feather.onStateChange(currentUser => {
  console.log(`The current user is: ${JSON.stringify(currentUser)}`);
});

unsubscribe();

To sign in:

feather
  .newCurrentCredential({
    email: "foo@example.com",
    password: "pa$$w0rd"
  })
  .then(credential => {
    if (credential.status !== "valid")
      throw new Error("Email or password is incorrect.");
    return feather.newCurrentUser(credential.token);
  })
  .then(currentUser => console.log(currentUser))
  .catch(e => {
    // Handle errors
  });

To sign in anonymously:

feather
  .newCurrentUser()
  .then(currentUser => console.log(currentUser))
  .catch(e => {
    // Handle errors
  });

To sign out:

feather
  .currentUser()
  .then(currentUser => currentUser.revokeTokens())
  .catch(e => {
    // Handle errors
  });

Development

If you do not have yarn installed, you can install it with npm install --global yarn.

Run the tests:

$ yarn install
$ yarn test
0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago