getCurrentUserData() {
let apiUrl='apiurl.io/user';
let data: Observable<any> = this.http.get(apiUrl+localStorage.getItem("uid").replace(/['"]+/g, '')+'?_format=json');
data.subscribe(result => {
this.currentUserData = result;
console.log(result);
})
}
Remember that if you only get the first string then you might miss “+”. As he said in the thread that is important when you want to replace more than one.
Thanks again. I’ve tried adding /g for global replacement but .ts file doesn’t seem to recognize the /g part. I may have missed “+” too.
Upon testing other things, I’ve found another solution.
I should’ve just added JSON.parse( localStorage.getItem(“uid”) ). It returned the value without the “” and is now displaying the proper apiurl.io/user/(uid)?_format=json