Hello,
Using the smart view could I make a call to another API (not the forest models, or routes), to display this data on the admin side?
For example, using useEffect.
Thanks in advance,
Isadora
Hello,
Using the smart view could I make a call to another API (not the forest models, or routes), to display this data on the admin side?
For example, using useEffect.
Thanks in advance,
Isadora
Hi @Isadora_Rebelo ,and welcome to our community!
After installation, Forest Admin will “only” display the data present on your database (the one you have specified during the set up).
Then, you can totally fetch external data to reconciliate different datasources into your Forest Admin (not coming from your database) such as Stripe payments, Hubspot companies, External doc from AWS.
For this, you can use smart collections.
Here are a few examples:
Hope this helps.
Hi @louis!
First, thank you for the fast reply, I was trying to apply it but I don’t feel like it’s what I’m looking for. I have Treezor cards that I want to display on my users, so not a different collection, but just call it in a collum at Forest Admin. Like, implement in on the module?
I’m not sure if I’m making myself clear but basic I want to call Treezor specific information on my already existing collections. That’s why I thought first on the smart view.
Thanks for the details, I think I have a better understanding of your need now. No Smart Views are required here.
You can consume the Treezor API to fetch and display data directly in your existing users collection. This can be done through the use of Smart Fields. It will basically add a new (virtual) column in your UI.
const { collection } = require('forest-express-sequelize');
// This file allows you to add to your Forest UI:
// - Smart actions: https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions
// - Smart fields: https://docs.forestadmin.com/documentation/reference-guide/fields/create-and-manage-smart-fields
// - Smart relationships: https://docs.forestadmin.com/documentation/reference-guide/relationships/create-a-smart-relationship
// - Smart segments: https://docs.forestadmin.com/documentation/reference-guide/segments/smart-segments
collection('orders', {
actions: [],
fields: [{
field: 'user treezor card',
type: 'String',
get: (user) => ({
// API call here
}),
}],
segments: [],
});
Keep in mind this will create one API call per record in your collection. If you are displaying 100 records per page, it could degrade performance a bit
Bonus: If you are on forest-express-sequelize
, I suggest you use afterFind
Sequelize hooks to create one single API call for all records per page and load the Smart Fields all at once. Here’s a step-by-step how-to guide on that.
Cheers,