Can’t get term id for category archive

To get term_id of current taxonomy, use the following code snippet

$queried_object = get_queried_object();
$term_id = $queried_object->term_id;