@usepoodle/poodle-js
Version:
Poodle JavaScript and TypeScript SDK
36 lines (35 loc) • 1.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const src_1 = require("../src");
// Initialize the client with your API key
const client = new src_1.PoodleClient({
apiKey: 'your-api-key-here',
});
// Example function to send an email
async function sendTestEmail() {
try {
const response = await client.sendEmail({
from: 'sender@yourdomain.com',
to: 'recipient@example.com',
subject: 'Test Email from Poodle SDK',
html: '<h1>Hello from Poodle!</h1><p>This is a test email sent using the Poodle JavaScript SDK.</p>',
text: 'Hello from Poodle! This is a test email sent using the Poodle JavaScript SDK.',
});
console.log('Email API call successful:', response.message);
}
catch (error) {
// Log the basic error message
console.error('Failed to send email:', error.message);
// Check if it's a PoodleError for more details
if (error instanceof src_1.PoodleError) {
console.error('Status Code:', error.statusCode);
console.error('Specific Details:', error.details);
}
else if (!(error instanceof Error)) {
// Handle cases where error might not be an Error instance
console.error('An unknown error occurred:', error);
}
}
}
// Run the example
sendTestEmail();