2017-12-02 15 views
0

変数に基づいて特定のユーザーに固有のAPIを消費しようとしています。文字列内の変数を連結してURLを作成する

このように、私がこれを達成するために書いたスクリプトは次のとおりです。私は変数を${cookieuid}という文字列で解析してURLを形成しています。

getBellNotification() { 
    let cookieuid = this.currentUser; 
    let headers = new Headers(); 
    this.authorizeHeaders(headers); 
    return this.http.get(
     this.config.apiUrl + 'api/supplier-notification/${cookieuid}?_format=json', { 
      headers: headers 
     } 
    ) 
     .map(response => response.json()) 
     .catch(this.handleErrorObservable); 
} 

私は望ましくない特殊文字で、以下の結果を得るよう期待どおりに動作していない:私は間違っ

http://<url>/api/supplier-notification/$%7Bcookieuid%7D?_format=json 

何をやっているとどのように私はそれを達成することができますか?

私は他の方法を試しましたが、それでも動作させることはできません。

答えて

1

この

getBellNotification(){ 
     let cookieuid = this.currentUser; 
     const url = `${this.config.apiUrl}/api/supplier-notification/${cookieuid}?_format=json`; 
     let headers = new Headers(); 
     this.authorizeHeaders(headers); 
     return this.http.get(url, { headers: headers }) 
     .map(response => response.json()) 
     .catch(this.handleErrorObservable); 
    } 
+0

を試してみてはあなたにSajeetharanをありがとうございます。私はこのように他の方法を試みたurlPre = 'API /サプライヤー通知/'; let urlPost = '?_format = json';次に+ – youi

関連する問題