<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: *');

require '../../modelo/subcategoria.php';
$response = array();

if (isset($_POST['id_subcategoria'])) {
    $id_subcategoria = $_POST['id_subcategoria'];
    $subcategorias = Subcategoria::mdlGetSubcategoriaById($id_subcategoria);

    if (!$subcategorias) {
        $response['response'] = 'error';
        $response['data'] = 'No se encontraron subcategorias';
    } else {
        $response['response'] = 'success';
        $response['data'] = $subcategorias;
    }
} else {
    $response['response'] = 'error';
    $response['data'] = 'Datos incompletos';
}

echo json_encode($response);
return;