Error: "Uncaught (in promise): [object Object]

Error occurs when i try to post in get method to rest api. but in postman it working perfectly.

 public cartview() {
let localaccesstoken = localStorage.getItem('token');
let apiUrl = this.urlService.apiUrl+'cart?access_token='+localaccesstoken;
return new Promise((resolve, reject) => {
  console.log("test : "+apiUrl);
      .subscribe(res => {
        console.log("w3cert Url : "+JSON.stringify(res));

      }, (err) => {
        console.log('w3cert : '+reject(err));

In console log shows an api. I copied that api and posted in postman it working. but in app it shows error

Error: “Uncaught (in promise): [object Object]”

how did you save your token in the local storage? Is it a string?

yes, i save a token in string

Did you save an object which you JSON.stringify()? If you did I suggest that you should JSON.parse(localStorage.getItem(‘token’)).

When i tried that it shows : ERROR SyntaxError: “JSON.parse: unexpected character at line 1 column 1 of the JSON data”

Did you try to log the localaccesstoken after getting the value in localstorage? If it shows your token I think we’re looking at a different problem here.

this is my log. in that token shows correctly

I see it’s not the token. Well I’m out of ideas but I suggest that you check your apiURL maybe you missed something.

i try log for apiurl. and i copied that and posted in postman it work perfectly. only in app it shows this error

since this is a promise error, i think you should try to return resolve and reject, to see if this solves it.
because everything else seems to be ok to me. What i miss in your promise is just returning resolve and reject.

Try converting your subscribe statement to promise before resolving.

http.get().toPromise().then((res) => {
}).catch((err) =. {