Fix TypeError when saving new API key