最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论