foxford / ulms-profile-js

JavaScript API-client for Profile service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ProfileJS

JavaScript API-client for Profile service

Installation

npm install --save @ulms/profile

Example

import {
  FetchHttpClient,
  SimpleTokenProvider,
  HttpProfileResource
} from '@ulms/profile'

const TOKEN = 'jwt-token'
const id = '123'
const ids = ['123', '456', '789']
const scope = '456'

const profile = new HttpProfileResource(
  'https://example.com',
  'api/v1/profile',
  new FetchHttpClient(),
  new SimpleTokenProvider(TOKEN)
)

// retrieving profile data
profile.getProfile(id, scope)
  .then((response) => {
    console.log('[response]', response)
  })
  .catch((error) => {
    console.log('[error]', error)
  })

// retrieving list of profiles
profile.listProfiles(ids, scope)
  .then((response) => {
    console.log('[response]', response)
  })
  .catch((error) => {
    console.log('[error]', error)
  })
  
// updating some attributes
profile.updateAttributes(id, scope, {role: 'user'})
  .then((response) => {
    console.log('[response]', response)
  })
  .catch((error) => {
    console.log('[error]', error)
  })

About

JavaScript API-client for Profile service

License:MIT License


Languages

Language:JavaScript 100.0%