Maybe this condition is wrong.
Do you mean this?

```
if ((typeof data[1]) === 'string' && data[1] !== 'error') {
  ...
}
```