比较来自服务器的字符串的较短方法

时间:2018-11-06 08:45:31

标签: string typescript angular6

我正在编写代码,比较来自服务器的错误是否与我初始化的错误相同。这段代码很健壮,我需要一种更简洁的编写方式。

let errorCheck = 'We could not properly read the file, check that your file is a valid .csv file';

forkJoin([this._lookupService.getValues(), this._another_lookupService.getOtherValues()])
  .subscribe((result: [Array < Lookup1 > , Array < Lookup2 > ]) => {
    this.values= result[1];
  }, error1 => {
    if (errorCheck === error1) {
      // do something 
    }
  });

问题是,如果来自服务器的语句或字符串将来会更改,则会影响前端的此代码。因此,我正在寻找一种更好,更短的书写方式。

0 个答案:

没有答案