Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.
/ ulms-profile-js Public archive

JavaScript API-client for Profile service

License

Notifications You must be signed in to change notification settings

foxford/ulms-profile-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
  })