Ah, I needed to add to __layout.svelte - this is why you refer to the docs and other intro tutorials
Yeah, Iâm facing the same issue too. I will test out the Next-Strapi template blog and see how itâs implemented
Yep Iâm struggling with this now as well.
One way to get around it is to change the users-permissionâs settings in the users & permissions plugin, and tick find and findOne; but unfortunately this exposes all user details in the API which really doesnât seem wise.
But yes for some reason, the author field is not appearing in the posts JSON.
Found the same problem when I tested the strapi-next template blog Strapi Next.js Blog Starter. The author name doesnât appear.
Hereâs the json for the api request
{
"data": {
"id": 1,
"attributes": {
"title": "What's inside a Black Hole",
"description": "Maybe the answer is in this article, or not...",
"content": "Well, we don't know yet...",
"slug": "what-s-inside-a-black-hole",
"createdAt": "2022-06-30T08:27:20.671Z",
"updatedAt": "2022-06-30T08:27:20.671Z",
"publishedAt": "2022-06-30T08:27:20.305Z"
}
},
"meta": {}
}
Following this tutorial I found a problem with this step:
âLike the post
routes, Strapi doesnât, by default, allow anyone to access this route either. So, letâs edit permissions like how we did earlier for the Authenticated
role.â .
So, I thought to follow the same process of the post step as wrote, that means go to Settings â Role â Authenticated and find the new Auth section to enable the /auth/me API. But I couldnât find any Auth section so I couldnât enable any API.
I googled âadd custom api strapiâ and I found this tutorial, from Strapi: How to Create a Custom API Endpoint in Strapi . Following this tutorial, with the apposite code, I was able to enable the /auth/me API correctly.
Hope this can help somebody and thank you for the content.
For those who struggling with getting author username from rest api â
- First of all you should set in Settings â User and Permissions Plugin â Roles â Public ( Edit ) â User-permissions â User ( set find and findOne )
- Fetch should be like http://localhost:1337/api/posts/4?fields[0]=*&populate[author][fields][0]=username
End of course this tutorial is quite outdated, because routing in sveltekit changed in September 2022
End of course this tutorial is quite outdated, because routing in sveltekit changed in September 2022
Before reading an article, I always try to read comments like yours - such comments immediately put me out of my misery, allowing me not to step on the same rake again. Thank you for that comment If it doesnât take much of your time, could you please correct the article. If you can, would you be so kind as to do a good deed for young people