I have an App Updates Collection
const AppUpdates: CollectionConfig = {
slug: "app-updates",
admin: {
useAsTitle: "heading",
},
auth: {
useAPIKey: false,
},
access: {
read: () => true,
},
fields: [
// additional fields
{
name: "poster",
type: "upload",
label: "Upload Thumbnail",
relationTo: "media",
admin: {
hidden: true,
},
},
{
name: "body",
type: "textarea",
required: true,
},
{
name: "buttonLink",
type: "text",
label: "Learn more URL",
},
],
};
export default AppUpdates;
When I try to access this data via API I can't get the Image URL. Here's a media collection.
const Media: CollectionConfig = {
slug: "media",
upload: {
staticDir: path.resolve(__dirname, "../../media"),
// Specify the size name that you'd like to use as admin thumbnail
adminThumbnail: "thumbnail",
imageSizes: [
{
height: 400,
width: 400,
crop: "center",
name: "thumbnail",
},
{
width: 900,
height: 450,
crop: "center",
name: "sixteenByNineMedium",
},
],
},
fields: [],
};
I have tried to access it by adding depth=1 in params but it didn't work. It can be the authentication issue I guess.
Payload -> localhost:4000
React App -> localhost:3000
React Code
const fetchData = async () => {
try {
const response = await axios.get(
"http://localhost:4000/api/app-updates?depth=1"
);
setData(response.data.docs);
console.log("Data from CMS: ", response.data);
} catch (error) {
console.error("Error fetching data:", error);
}
};
How can I make sure that I get complete data from an API?