<?php

use api\classes\API;

session_start();
require_once "{$_SERVER['DOCUMENT_ROOT']}/api/classes/API.php";

$API = new API();

if ($API->request_method === 'GET') {
    $breadcrumbJson = '[]';

    if (isset($_SESSION['breadCrumbArray'])) {
        try {
            $breadcrumbJson = json_encode($_SESSION['breadCrumbArray'] ?? [], JSON_THROW_ON_ERROR);
        } catch (JsonException $e) {
            error_log($e->getMessage());
            $breadcrumbJson = '[]';
        }
        $_SESSION['breadCrumbArray'] = [];
    }

    echo $breadcrumbJson;
}