import {
Royaltyport,
RoyaltyportAuthenticationError,
RoyaltyportRateLimitError,
RoyaltyportValidationError,
} from '@royaltyport/sdk';
const royaltyport = new Royaltyport({ apiKey: 'rp_your_token_here' });
try {
const { data } = await royaltyport.projects.list();
} catch (error) {
if (error instanceof RoyaltyportAuthenticationError) {
console.error('Invalid or expired token');
} else if (error instanceof RoyaltyportRateLimitError) {
console.error(`Rate limited. Retry after: ${error.retryAfter}`);
} else if (error instanceof RoyaltyportValidationError) {
console.error('Invalid request:', error.message);
} else {
throw error;
}
}