I'm working with a function that has multiple parameters:
public find(
cadnum: string,
pagesize: number,
startid?: string
): Observable<any> {
let url = "";
if (cadnum) {
url+= "?cadnum=" + cadnum;
}
if (pagesize) {
url+= "&pagesize=" + pagesize;
}
if (startid) {
url+= "&startid=" + startid;
}
return this.httpClient.get(url);
}
It seems like there may be a better way to handle checking and concatenating the URL string, especially when dealing with more parameters. Any suggestions on how to improve this process?