API : resource NOT FOUND
-
I'm trying to make an API of my application using CodeIgniter 4 (PHP, Javascript), but when I clicked Send(in postman) with URL: http://localhost:8080/lampiran, it always showing '404 Not Found'(The requested resource
/lampiran
was not found). This is my controller :class Lampiran extends ResourceController
{
protected $model = 'App\Models\lampiranModel';
protected $format = 'json';public function index() { $data = \[ 'message' => 'success', 'data\_lampiran' => $this->model->findAll() \]; return $this->respond($data, 200); }
.....
and this is my route
$routes->get('lampiran', 'Lampiran::index');
-
I'm trying to make an API of my application using CodeIgniter 4 (PHP, Javascript), but when I clicked Send(in postman) with URL: http://localhost:8080/lampiran, it always showing '404 Not Found'(The requested resource
/lampiran
was not found). This is my controller :class Lampiran extends ResourceController
{
protected $model = 'App\Models\lampiranModel';
protected $format = 'json';public function index() { $data = \[ 'message' => 'success', 'data\_lampiran' => $this->model->findAll() \]; return $this->respond($data, 200); }
.....
and this is my route
$routes->get('lampiran', 'Lampiran::index');
It sounds like you have a web server running by the nature of your error message, so it's probably a routing issue. Some MVC frameworks will do this automatically, but gonna assume that CodeIgniter doesn't. Both have their pros and cons... Anyway, here ya go... [URI Routing — CodeIgniter 4.5.5 documentation](https://codeigniter4.github.io/userguide/incoming/routing.html)
Jeremy Falcon
-
It sounds like you have a web server running by the nature of your error message, so it's probably a routing issue. Some MVC frameworks will do this automatically, but gonna assume that CodeIgniter doesn't. Both have their pros and cons... Anyway, here ya go... [URI Routing — CodeIgniter 4.5.5 documentation](https://codeigniter4.github.io/userguide/incoming/routing.html)
Jeremy Falcon