Skip to content

Commit

Permalink
Update example to use http request 2 (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt authored Dec 4, 2024
1 parent 896ca67 commit d275869
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions examples/service-alias/service-alias.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ contract ServiceAlias is Suapp {
request.method = "GET";
request.timeout = 1000;

bytes memory response1 = Suave.doHTTPRequest(request);
Suave.HttpResponse memory response1 = Suave.doHTTPRequest2(request);

// Make the request to the http endpoint
request.url = "https://example.com";
bytes memory response2 = Suave.doHTTPRequest(request);
Suave.HttpResponse memory response2 = Suave.doHTTPRequest2(request);

require(keccak256(response1) == keccak256(response2), "Strings should be equal");
require(response1.status == 200, "Status should be 200");
require(response2.status == 200, "Status should be 200");

require(keccak256(response1.body) == keccak256(response2.body), "Strings should be equal");
return abi.encodeWithSelector(this.exampleCallback.selector);
}
}

0 comments on commit d275869

Please sign in to comment.