Need help - Axios - Uncaught (in promise) Error: Request failed with status code 500

Hello,
I am working on the freecodecamp Laravel project linked below:

Everything worked fine until 3:30:57 (time in the YT lecture).
Instead of getting the propper alert I get errors:

POST http://127.0.0.1:8000/follow/1 500 (Internal Server Error)
dispatchXhrRequest @ app.js:285
xhrAdapter @ app.js:119
dispatchRequest @ app.js:765
Promise.then (async)
request @ app.js:542
Axios. @ app.js:567
wrap @ app.js:1131
followUser @ app.js:1924
invokeWithErrorHandling @ app.js:39508
invoker @ app.js:39833
original._wrapper @ app.js:45192

Uncaught (in promise) Error: Request failed with status code 500
at createError (app.js:699)
at settle (app.js:960)
at XMLHttpRequest.handleLoad (app.js:168)
createError @ app.js:699
settle @ app.js:960
handleLoad @ app.js:168
Promise.then (async)
followUser @ app.js:1924
invokeWithErrorHandling @ app.js:39508
invoker @ app.js:39833
original._wrapper @ app.js:45192

In my index.blade,php file I have:

In my FollowButton.vue I have:

In my web.php I have:

In my FollowsController.php I have:

I hope someone here could help me resolve this.
Thanks.

Hello! Welcome to the community :slight_smile:!

You would need to check the error log to understand what happens :slight_smile:. An error 500 means that the server throw an exception from which it could not recover.

Where the error_log is will depend on your project configuration. It may be in /var/log/apache/error_log (if you connect through SSH to homestead).

Thank you!
And regarding this matter…
I don’t use homestead at the time.
The whole project is in the local folder C:\cmder\freeCodeGram
The only log file I found so far was laravel.log
This is my first Laravel project, by the way.

It seems that laravel.log contains all the relevant information.
Searching through the file for “error”, I found this:

What should I do now?

Just to let you know - I figured this out myself.
There was line of code missing in the FollowsController.php

And that was all.
It’s working fine again.

1 Like

I’m happy you solved it by yourself, so congratulations :partying_face:!

One thing that will work for every project: find and read the applicaiton logs (whatever and however the application/software/OS keeps them). There’s always one :slight_smile:.

PD: sorry for not replying before, I forgot to track the thread :sweat_smile:! You should, however, reply to the posts of others so they get notified regardless :slight_smile:.