I am brand new to magento 2 so forgive me if this is pretty basic. I am using magento 2.3 and am having issues researching or finding a solution for something that seems super simple. I just need to grab the category name or ID of the current product I am viewing so I can add it to a data attribute in the html.
Only solution I found that worked was using the object manager which I read is a bad thing to do. The other solutions used the registry which is deprecated.