how to store the result of the JSON-RPC response to a variable?

Asked on March 08, 2020

{"result": 204, "id": "1", "jsonrpc": "2.0"}

this is the result of a json-rpc request for total count of the database. so the total number of documents in the databse is 204. how to grab the value 204 and store it in a variable so that i can use it to perform some arithmetic operations? in angular

Replied on March 09, 2020
Suppose your JSON is 

const JSON_DATA = {"result": 204, "id": "1", "jsonrpc": "2.0"};

You can fetch any field as

const res = JSON_DATA['result'];

console.log(res); //204

Write Answer

©2024 | Privacy Policy | Contact Us