Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Liano_Isaac's avatar

API WITH VUEJS

Hello, let's suppose that my application, a Post belongs to a user. In the PostController in the create method, we look for all the users ($users = User::all()), and we call the users in the blade through the foreach. Now, how do I get these same users when registering a Post using API with vueJs, when I can't use create method? Grateful!

0 likes
4 replies
Sinnbeck's avatar

Sorry I am not quite sure what part you are struggling with. Can you show a simple blade example?

wingly's avatar

If understand what you are saying for some reason you need the $users to be available at the Vue page where you can create a post. In the context of Vue + API the way todo it is to have a dedicated endpoint to grab the users. At your Vue page you can then call this endpoint and get the users. Still don't understand the need of getting all users but you know better.

1 like
Liano_Isaac's avatar

@wingly I understood your opinion. Sorry for the silly question, I'm new to the API.

Sinnbeck's avatar

@Liano_Isaac maybe you should give inertia a shot. It feels almost like working with laravel/blade, just with vue for the frontend

1 like

Please or to participate in this conversation.