Bing Wang
Bing Wang

Reputation: 71

When building Chainlink.Request, what is the difference between path and copyPath in Chainlink?

function requestMWAPrice(string _coin, string _market)
  public
  onlyOwner
  returns (bytes32 requestId) 
{
  Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
  req.add("endpoint", "mwa-historic");
  req.add("coin", _coin);
  req.add("market", _market);
  req.add("copyPath", "data.-1.1");
  req.addInt("times", 100);
  requestId = sendChainlinkRequestTo(oracle, req, oraclePayment);
}

We need to specify the path for access the real value we want. Notice the line, req.add('copyPath', "data.-1.1"), but sometimes we would use req.add('path', ...), when should we use copyPath and when should we use path?

Upvotes: 1

Views: 67

Answers (1)

Harry Papacharissiou
Harry Papacharissiou

Reputation: 856

As specified in the adapter descriptions, path/jsonParse is used for when you're parsing a result from a HTTP GET or POST adapter, and copyPath is when you're parsing a result from an external adapter

Upvotes: 1

Related Questions