Any idea from anyone?
Mar 24, 2022
10
Level 4
Displaying Pagination Link
I am trying to work on navigation on my laravel and nuxtjs navigation so i did this in my controller
public function index()
{
$posts = Post::orderBy('created_at', 'desc')->paginate(10)->through(fn($post) =>[
'id' => $post->id,
'title' => $post->title,
'body' => $post->body,
'excerpt' => $post->excerpt,
'updated_at' => $post->updated_at->format('Y/m/d H:i'),
]);
return response()->json($posts);
}
and in my NuxtJs file i did the following
<Component
:is="link.url ? 'NuxtLink' : 'span'"
v-for="(link, i) in posts.links"
:href="link.url"
to="/"
:key="i"
v-html="link.label"
class="px-1"
:class="link.url ? '' : 'text-blueGray-500'"
/>
The navigation was displayed but the link did not output correctly as it was output like this http://localhost/api/posts?page=2 which is wrong and goes to different page because the nuxtjs url is localhost:3000
How can i correct this?
Please or to participate in this conversation.