I would like to know if this feature is available as well. In particular, having a way to access something like the data stored in the layout object of useCMEditViewDataManager. This would allow us to (easily) apply conditional logic based on apiID.
@Louai_Kelani, if you are attempting to do something similar (conditional parameters on a button), the following workaround serves as a temporary solution: retrieve the apiID by destructuring the window.location.pathname.
import React, { useState, useEffect } from 'react'
import axios from 'axios'
const MyInjectedComponent = (props) => {
const [apiID, setApiID] = useState(null)
const [responseData, setResponseData] = useState({})
useEffect(() => {
// eslint-disable-next-line no-undef
const apiIDFromUrl = window.location.pathname.split('::')[1].split('.')[0]
setApiID(apiIDFromUrl)
;(async () => {
try {
// NOTE: Many collection-types are pluralized, so you may need to
// transform the apiID to work for your purposes
const { data } = await axios.get(`${process.env.API_URL}/${apiID}s`)
setResponseData(data)
} catch (error) {
console.error(error)
}
})()
return () => {
// ... Cancel axios request
}
}, [])
return <button onClick={() => console.log(responseData)}>{apiID}</button>
}
export default MyInjectedComponent