nickywan123
3 months ago
394
1
Laravel

cannot send request for API in postman

Posted 3 months ago by nickywan123

I am trying to test my route API on laravel (Valet) and I set up a simple route to get all the articles on my article table.

api.php:

// List articles
Route::get('articles','[email protected]');

ArticleController:

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //Get articles
        $articles = Article::paginate(15);

        //Return collection of article as a resource
        return ArticleResource::collection($articles);
    }

So my db has a number of articles and I am testing my API on postman through GET request.

My project url is article.test and I wrote:

http://article.test/api/articles

I type http://article.test/api/articles on my browser and it does return the data.

However, it could not return any response and I was wondering if I need to make some kind of configuration on postman or my URL is wrong?

Please sign in or create an account to participate in this conversation.