cant seem to convert string to int

here my code. It is seeing if the string starts with x for the x value of the joystick. Im then outputting it as pwm. The value is read in from a hc12. The error is included at the bottom of the code to prevent smileys.

    if (data.charAt("" + 0) == 'x')
    {
      data.remove(0,1);
      int rawxval = data.toInt;
      int newxval = rawxval - 540;
      analogwrite(newxval);
      
    }


cannot convert 'String::toInt' from type 'long int (String::)() const' to type 'int'

I also tried atoi getting this error:

    if (data.charAt("" + 0) == 'x')
    {
      data.remove(0,1);
      int rawxval = atoi(data);
      int newxval = rawxval - 540;
      analogwrite(newxval);
      
    }
error: cannot convert 'String' to 'const char*' for argument '1' to 'int atoi(const char*)'

Silly me! wondered why it wouldn't work!