URLSearchParams()
と表示される奇妙な問題があります。var search
(つまり、変数名をvar otherName
に変更した場合)を定義した場合にのみ機能します。URL2のURLSearchParams()で奇妙な問題が発生する
ただし、何らかの理由で、名前がsearch
の場合にのみ機能します。それはまったく論理的ではありません。
ここで何が起こっているかについてのアイデアはありますか?
constructor(http) {
this.http = http;
this.genre = null;
this.dishes = null;
//this one works fine
var search = new URLSearchParams();
search.set('order', '-ordersNo');
//Here is the issue (to make it work, I need to remove the previous search declaration, and rename the below var limit to search)
var limit = new URLSearchParams();
limit.set('limit', '2');
this.http.get('https://example.com/classes/Mn', { limit }).subscribe(data => {
this.dishes = data.json().results;
});
this.http.get('https://example.com/classes/Genre',{ search }).subscribe(data => {
this.genre = data.json().results;
});
詳細を教えてください。 –
あなたの提案はうまくいっていますが、検索を別の名前に変更すると、それが動作を停止する理由がわかりません!本当に奇妙な!! –