从网址角度使用JSON加载自定义翻译

问题描述

下面的代码负责从url加载翻译,但是他们必须联系向我返回json的终结点,但是在这种情况下,翻译没有加载是什么原因?

TypeScript:

@Injectable({
  providedIn: 'root'
})
export class TranslationService implements TranslateLoader {

  constructor(private http: HttpClient,private globalService: GlobalService) {}

    getTranslation(): Observable<any> {
      const urlTocall = url
      const authorizationData = 'Basic ' + btoa(user + ':' + pwd);
      const headerOptions = {
        headers: new HttpHeaders({
            'Content-Type':  'application/json',Authorization: authorizationData
        })
    };
    
      return this.http.get(urlTocall,headerOptions ).pipe(map((res: any) => {
          return res.data.map(item => {
            return item.attributes.documento;
          });
      }));
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)