0
votes

I am creating a restful api using laravel dingo package.When i am giving url localhost:8000/hello.it is showing error NotFoundHttpException in RouteCollection.php line 161:

Here is my route.php

/* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */

$api = app('Dingo\Api\Routing\Router');

Route::get('/', function () {
  return view('welcome');
});

$api->version('v1', function($api) {
$api->get('hello', function(){
     return "Hello";
});

   });

Here is my api.php code. I have set my api.php

'transformer' => env('API_TRANSFORMER', Dingo\Api\Transformer\Adapter\Fractal::class),

'formats' => [

    'json' => Dingo\Api\Http\Response\Format\Json::class,

],

'domain' => env('API_DOMAIN', 'api.restapi.com'),
'name' => env('API_NAME', 'rest api'),
   'version' => env('API_VERSION', 'v1'),

After giving route it is showing error.i have tried in every possible way.please help me out. Thank you in advance.

1

1 Answers

0
votes

If you have prefix API_PREFIX set then the route you've added corresponds to

https://localhost:8000/api/v1/hello

Assuming the prefix is api

If no prefix is set then it's

https://localhost:8000/v1/hello