I solved it by making a controller in the plugin. And making a request to the endpoint of a plugin inside another plugin.
async function fetchCategory() {
const url = "/{pluginUrl}/categories"
try {
const {data} = await axios.get(url)
setCategoryData(data.results)
} catch (err) {
console.log(err)
}
}