Retrieve paginated list of messages
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('chat/messages@1.0.2');
// Use the profile
const result = await profile
.getUseCase('GetMessages')
.perform({
destination: 'general',
limit: 2
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"destination": "general",
"limit": 2
}
{
"messages": [
{
"id": "1",
"author": {
"id": "U01",
"username": "user1"
},
"createdAt": 1643835553658.259,
"text": "test 1"
}
]
}