POST http://localhost:8000/api/projects/ 500 (Internal Server Error)


I’m working on a rest api project, I’m using Laravel and Angular. To resume, my project is like a project manager. I’ve got 4 tables: user, project, project_user and status. enter image description here So when a user create a project, he writes just the name and the project is created. The creator_id is the current user id. For the backend, I’m using Laravel JWT for the auth. And this is the code of the controller to create a project: enter image description here

Project model:

class Project extends Model
    protected $fillable = [
        'name',  'creator_id', 'status_id'

    protected $hidden = [
        'created_at', 'updated_at'

    protected $table = 'projects';

    public function users()
        return $this->belongsToMany(User::class)->select( 'email', 'date_of_birth', 'firstname', 'lastname');

    public function status()
        return $this->belongsTo(Status::class);

So the route in backend works, I tried with Postman and all is good. But I’ve got a problem with this route to create a project in frontend. It doesn’t work and I’ve got the error 500 (Internal Server Error). When I inspect the web page, in security, I’ve got this message:
enter image description here

This is my angular code:

export class AddProjectComponent implements OnInit {

  project = {
    name: '',

  submitted = false;
  constructor(private projectService: ProjectService) { }

  ngOnInit() {

  createProject(): void {
    const data = {
        response => {
          this.submitted = true;
        error => {

  newProject(): void {
    this.submitted = false;
    this.project = {
      name: ''


  create(data): Observable<any>{
    return`http://localhost:8000/api/projects/`, data);

I don’t know why it doesn’t work because my user is well connected, i’ve got his auth_token in the local storage.

Someone can help me pls ? ^^

I think I have put the most useful files but if they are missing I can add them to you.

Thanks in advance

Source: Angular Questions

Categorized as angular, jwt, laravel, php, typescript Tagged , , , ,


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us