How can httpParams quickly add parameters?

the method of adding parameter content to httpParams. The official way to write it is:

const httpParams = new HttpParams().set(key,value).set(key,value).set(key.value);

if you want to add multiple parameters, you have to keep .set (), which feels troublesome, and then comes up with an optimized way to write it:

let data = {
    aaa:"aaa",
    bbb:"bbb",
}
const httpParams = new HttpParams();
for(let key in data){
    httpParams.set(key,data[key]);
}

but if you do this, the parameters will not be passed in. Why, is there any solution?

Feb.28,2021

const httpParams = new HttpParams();
for(let key in data){
    httpParams = httpParams.set(key,data[key]);
}

Don't bother, just shove your value into the constructor

const httpParams = new HttpParams({
    fromObject: data
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e92064-13a2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e92064-13a2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?