use Drupal\Core\Config\ConfigFactoryInterface;
...
/**
* Configuration Factory.
*/
protected ConfigFactoryInterface $configFactory;
/**
* Constructs an object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
Add '@config.factory' argument to .services.yml file