2017-06-17 82 views
0

我想做一個插入語句,它有兩個參數用戶ID和商店。但它似乎並沒有從@角/ HTTP工作如何做一個角度多個參數的獲取請求

addToFavorites(Store,User){ 
    return this.http.get('http://localhost:8888/PeopleService/GetStore&Offers/Favorite.php?STORE='+ Store +'&User='+User) 
    .do(this.logResponse) 
    .map(this.extractData) 
    .catch(this.catchError); 
} 
+0

你是什麼意思不工作?任何錯誤?什麼是迴應?請閱讀[mcve] –

+0

對不起,我忘了添加錯誤「SyntaxError:JSON解析錯誤:意外的標識符」查詢「」和「TypeError:error.json不是一個函數(在'error.json()','錯誤。 json'未定義)「 – Nouf

+0

只是[編輯]的職位,幷包括細節,請 –

回答

0

使用URLSearchParams

addToFavorites(Store,User) { 
    const params = new URLSearchParams(); 
    params.append('STORE', Store); 
    params.append('User', User); 
    return this.http.get(
     'http://localhost:8888/PeopleService/GetStore&Offers/Favorite.php, 
     { search : params} 
    ) 
    .map(v => this.extractData(v)) 
    .catch(err => this.catchError(err)); 
}