@ensemblebr/shared-api

v7.6.0

Published

Ensemble Shared API

Downloads

52

Readme

Ensemble API

Exemplo de uso:

import api, { useApi } from 'ensemble-shared-api';

// configura prefixo de URL
api.setBaseURL('https://api.example.com');
// Configura token de autenticação (Bearer)
api.setAuthToken('7538ry1he0uhd20rh1-rhd3qw408ryh4208fwqgh0t');

export default () => {
    const [user, meta] = useApi('/user', {policy: api.policy.NETWORK_ONLY});
    
    if(meta.loading) return (<span>LOADING...</span>);
    
    return (
        <div>
            Loggeduser: {user.name}
        </div>
    );    
};