skip to Main Content

I am calling this function:

Route::get('/person', function (){
 $person=[

   'first_name'=>'dildar',
   'last_name'=>'Muhammad',

 ];
 return $person;
}); 

and I browse https://astrolabe.ml/api/person but I got error not found page 404

enter image description here

it does work on new laravel project but I did not found any clue from that why it does not my work.

2

Answers


  1. emphasized texttry to replace this

    Route::get('/person', function (){
    

    to

    Route::get('person', function (){
    

    Edit:
    remove everything and try this:

    Route::get('test', 'HomeController@index');
    

    HomeController.php

    public function index(){
    dd('x');
    }
    

    then run:

    php artisan optimize
    

    finally go to www.example.com/api/test

    Login or Signup to reply.
  2. Update your code

    Route::get('/person', function (){
     $person=[
    
       'first_name'=>'dildar',
       'last_name'=>'Muhammad',
    
     ];
     return response()->json($person); // Update this thing
    }); 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search