如何撤销持票人令牌并刷新?

If the bearer token is near the end, a refresh controller to create a new token. The parameter to be received is the current token if it is to be returned, the current token is good, if not, create a new token. related codes are available in below.

I used the swagger framework in PHP

public static function checkToken($token)
    {
        $t = new Token();
        $t->loadByTokenValue($token);

        if (JMT::isLoaded($t)) {
            $expireDate     = $t->getExpires()->expires;
            $convertedDate  = new DateTime($expireDate);
            $since_start    = $convertedDate->diff(new DateTime());
            if ($since_start ->i < 2 ) {
                return true;
            }
            return false;

        }
        return true;
    }

public function test() {
        $currentToken   = $this->getBearerToken();
        $isExpired      = Token::checkToken($currentToken);
        if ($isExpired) {
            $u = new User();
            $u->loadByUserkey($currentToken);
            Token::invalidateToken($currentToken);
            $t = Token::create( $u, 'web' );RestUtils::sendResponse(200,
                $this->createStandardResponse(null, "Token is changed", $t));
        }
        else {
            RestUtils::sendResponse(200, $this->createStandardResponse(null, "Token is not expireds", $currentToken));
        }
    }

I wrote some code like this but when ı tested "/authtest" url in swagger ui, I got a error like this

"
Code: Undocumented    
Details:
TypeError: Failed to fetch"

How can ı solve this problem?

thanks everyone!