toInt error when converting character of string to interger with the following code:

int foo = bar[1].toInt;


or

int foo = bar[1].toInt();


I get this error

request for member 'toInt' in '*(bar + 1u)', which is of non-class type 'uint8_t {aka unsigned char}'


the context for this is bar is the response from a HTTP client over web sockets
The Arduino function toInt requires a String object.
You're passing it a single character, not a String.

int foo = String(bar[1]).toInt();