Argument of type 'Params' is not assignable to parameter of type 'string'

I have passed data via snapshot and am now trying to receive it but am getting the following error

"[ts] Argument of type 'Params' is not assignable to parameter of type 'string'."

When I sent the data I done a JSON.stringify and the data looked like this.

[
  {
    "caseData": "{\"getAllInfo\":{\"ticket\":{\"internalNum\":\"2500024035\",\"comp\":\"29\",\"reportedDate\":\"2018-07-20\",\"reportedTime\":\"00:00\",\"forceNumCharge\":\"7035551\",\"offenceSequence\":\"1\",\"aggrievedParty\":\"1\"}}}"
  }
]

Now when I try to retrieve the data and do a JSON.parse I get the error mentioned above.

this.caseData = JSON.parse(this.activatedRoute.snapshot.params);

1 answer

  • answered 2018-11-08 08:17 RoadEx

    I may be wrong, but try with this.activatedRoute.snapshot.params['caseData']. In this case, you should probably put a debugger or a console.log(this.activatedRoute.snapshot.params) if you're doubting the way it's returned.