1

I need to set a header with my api response.

I tried like this

/**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    return Blog::all()->header('X-Total-Count', Blog::all()->count());
}

How to send this properly?

1 Answer 1

3

Based on the documentation, the following should work:

return response(Blog::all())
    ->header('X-Total-Count', Blog::all()->count());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.