0

We have Json RPC response in {},{},{}

We are unable to save the response as a variable but can see it via console.log() after doing Jsonrcp.parse(response) which we got from the below library

We are using the JsonRPC-Lite library https://www.npmjs.com/package/jsonrpc-lite.

This is our code

axios
    .post(
      "https://ipfs.infura.io:5001/api/v0/add?wrap-with-directory=true",
      data,
      {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      }
    )
    .then(function (response) {
                            this.setState({ apireturm: reponse.data });
      console.log(response.data);
    })
    .catch(function () {
      console.log("FAILURE!!");
    });
  • .then(function (response) { this.setState({ apireturm: array }); did you mean .then(function (response) { this.setState({ apireturm: response.data }); – Aymen Sep 22 '20 at 10:38
  • Also, please make sure ```this``` is in the context. You might want to try arrow function in promise handlers. – Sameer Kumar Jain Sep 22 '20 at 10:54
  • @Aymen Yes, it's response.data .. I corrected it. I am able to console.log it but not able to save it. I think it's mostly a problem of parsing of json-rpc. we tried a lot but it's not working. what do you think? – Yash Shukla Sep 22 '20 at 11:46

0 Answers0