2020-06-03 21:44:35 +02:00
|
|
|
import { get } from "builderStore/api"
|
2020-06-03 21:35:30 +02:00
|
|
|
|
2020-05-02 16:29:10 +02:00
|
|
|
/**
|
|
|
|
* Fetches the definitions for component library components. This includes
|
|
|
|
* their props and other metadata from components.json.
|
|
|
|
* @param {string} appId - ID of the currently running app
|
|
|
|
*/
|
2021-05-04 12:32:22 +02:00
|
|
|
export const fetchComponentLibDefinitions = async appId => {
|
2021-04-01 12:49:57 +02:00
|
|
|
const LIB_DEFINITION_URL = `/api/${appId}/components/definitions`
|
2020-05-02 16:29:10 +02:00
|
|
|
try {
|
2020-06-03 21:35:30 +02:00
|
|
|
const libDefinitionResponse = await get(LIB_DEFINITION_URL)
|
2020-05-07 11:53:34 +02:00
|
|
|
return await libDefinitionResponse.json()
|
2020-05-02 16:29:10 +02:00
|
|
|
} catch (err) {
|
2020-05-07 11:53:34 +02:00
|
|
|
console.error(`Error fetching component definitions for ${appId}`, err)
|
2020-05-02 16:29:10 +02:00
|
|
|
}
|
2020-05-07 11:53:34 +02:00
|
|
|
}
|