Laravel 8 Exception handler for ThrottleRequestsExcception doesn’t return json

I’ve migrated my Laravel 5.7 project to 8 and have an API endpoint called optouts which has a throttle on it. When I make post requests to this endpoint in quick succession, I should be given a JSON response rather than the HTML variant of the page. I’ve migrated over to the register and reportable method, here’s my PHP code:

<?php

namespace AppExceptions;

use IlluminateFoundationExceptionsHandler as ExceptionHandler;
use IlluminateHttpExceptionsThrottleRequestsException;
use Throwable;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var array
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var array
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        $this->reportable(function (ThrottleRequestsException $e, $request) {
            if ($request->is('api/*')) {
                return response()->json([
                    'message' => 'Too many requests.'
                ], 429);
            }
        });
    }
}

But when I make requests to my endpoint I’m still given the HTML variant, not the JSON page. What am I missing here?