php - Creating a forum with Laravel but having problems with Angular


I'm creating a forum with users, posts and comments with Laravel and now I have to use Angular but I'm new to it so I have no Idea where to begin.

I've tried to return the json data from my laravel application (a user for instance), but I don't know to get them from Angular.

public function index(){ $user_id = auth()->user()->id; $user = User::find($user_id); return response()->json($user,201); }

I'd be pleased if someone can help or recommend me something.




In your angular project, you will have to create a service.ts file. The service may contain your API calls related to the user model.

//run the command
ng generate service user

//In your user.service.ts file 
import { HttpClient } from '@angular/common/http';

export class UserService {

    constructor(private httpClient: HttpClient) { }

    API_URL = 'http://yourLaravelApiProject/public/api';

    userDetails() {
        return this.httpClient.get(`${this.API_URL}/yourApiUrl`);

Do well to read more on services, interceptors. Or try out the Angular tutorial Angular Tuorial

People are also looking for solutions to the problem: xml - How to make a xslt-tranformation with Saxon/C PHP-API


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.