javascript - Not able to fetch json data from a "SINGLE-TYPE" content-type in strapi - Stack Overflow

I used strapi as my backend for all my data flow, I created single-type content, this single type has d

I used strapi as my backend for all my data flow, I created single-type content, this single type has different ponents attached to it. After configuring all the single-types, I tried to fetch the data through rest Api, But I didn't got the json data as a response.

This is my json response

This is my single-type structure

I used strapi as my backend for all my data flow, I created single-type content, this single type has different ponents attached to it. After configuring all the single-types, I tried to fetch the data through rest Api, But I didn't got the json data as a response.

This is my json response

This is my single-type structure

Share Improve this question edited Jul 9, 2022 at 3:57 Abhijeet John Kujur asked Jul 8, 2022 at 9:59 Abhijeet John KujurAbhijeet John Kujur 1471 silver badge10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

So to get back all the data from the "single-type" the following procedure are:

  • After creating the single-Type content, Go to the settings of the strapi admin page and then click the Role option.

  • Click on the public tab.

  • locate permissions tab and search for the single-type you created and click on the single-type tab.

  • Then you will find the permissions for that single-type, tick on find option, there are other option too, tick it as per your needs.

  • After that you will see a api endpoint on the right side of the screen for that particular single-type.

  • Copy that endpoint.

  • Use your browsers or any api client like Postman etc to test the api endpoint.

Now the Main Trick es here

To get the result of the end point you have to type something like this:

http://localhost:1337/api/"your single-type name"?populate=*

This above code will list all the ponents and all its data inside of it will be displayed in the json response.

NOTE:

If there is any image data or any other media files inside the ponent it won't be displayed, so to to get that also along with other data you need to type:

http://localhost:1337/api/"your single-type name"?populate[your ponent name which contains that image data][populate]=*

When you type the api endpoint url your single-type name should be without double quotes

Follow this link : For More Information regarding how to handle the rest api in strapi

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745379947a4625176.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信