JavaScript / Node.js
Generate content using the TrendScribbr API from Node.js with axios.
javascript
const axios = require('axios');
const API_KEY = 'your-api-key-here';
const BASE_URL = 'https://your-domain.com/agents/api';
async function generateArticle(topic) {
try {
const response = await axios.post(`${BASE_URL}/articles/generate/`, {
content_type: 'article',
custom_topic: topic
}, {
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/x-www-form-urlencoded'
}
});
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
throw error;
}
}
// Usage
generateArticle('The Future of AI in Healthcare')
.then(result => console.log(result))
.catch(error => console.error(error));