Skip to content

Commit

Permalink
Merge pull request #1746 from demergent-labs/documentation_fetch
Browse files Browse the repository at this point in the history
add fetch documentation
  • Loading branch information
lastmjs authored Apr 18, 2024
2 parents 8cf55f7 + 0d296e6 commit aaa16c4
Show file tree
Hide file tree
Showing 174 changed files with 912 additions and 175 deletions.
2 changes: 1 addition & 1 deletion docs/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets.html

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions docs/authentication.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/azle.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/candid.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/candid_based_documentation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/canister_lifecycle.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/canisters_overview.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/caveats.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/cross_canister.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/cycles.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/debugging.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/deployment.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/deployment_candid_based.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/examples.html

Large diffs are not rendered by default.

328 changes: 328 additions & 0 deletions docs/fetch.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/get_started.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/hello_world.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/http.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/installation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/internet_computer_overview.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/limitations.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/management_canister.html

Large diffs are not rendered by default.

133 changes: 132 additions & 1 deletion docs/print.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/project_structure.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/query_methods.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/bitcoin.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/accept_message.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/arg_data_raw.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/arg_data_raw_size.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/call.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/call_apis.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/call_raw.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/call_raw128.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/call_with_payment.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/call_with_payment128.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/caller.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/method_name.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/msg_cycles_accept.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/msg_cycles_accept128.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/msg_cycles_available.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/msg_cycles_available128.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/msg_cycles_refunded.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/msg_cycles_refunded128.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/notify.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/notify_raw.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/notify_with_payment_128.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/reject.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/reject_code.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/reject_message.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/reply.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/call_apis/reply_raw.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/blob.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/bool.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/candid.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/empty.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/float32.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/float64.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/func.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/int.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/int16.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/int32.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/int64.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/int8.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/nat.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/nat16.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/nat32.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/nat64.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/nat8.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/null.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/opt.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/principal.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/record.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/reserved.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/service.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/text.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/variant.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/candid/vec.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/candid_decode.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/candid_encode.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/canister_apis.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/canister_balance.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/canister_balance128.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/canister_id.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/canister_version.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/data_certificate.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/instruction_counter.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/is_controller.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/performance_counter.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/print.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/set_certified_data.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/time.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_apis/trap.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/canister_methods.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/heartbeat.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/http_request.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/http_request_update.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/init.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/inspect_message.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/post_upgrade.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/pre_upgrade.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/query.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/canister_methods/update.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/environment_variables.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/bitcoin_get_utxos.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/canister_status.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/create_canister.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/delete_canister.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/deposit_cycles.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/ecdsa_public_key.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/http_request.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/install_code.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/raw_rand.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/sign_with_ecdsa.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/start_canister.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/stop_canister.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/uninstall_code.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/management_canister/update_settings.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/plugins.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/reference.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable64_grow.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable64_read.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable64_size.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable64_write.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable_bytes.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable_grow.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable_memory.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable_read.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable_size.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable_structures.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/stable_memory/stable_write.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/timers/clear_timer.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/timers/set_timer.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/timers/set_timer_interval.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/timers/timers.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference/wasm_binary_optimization.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference_http/autoreload.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference_http/environment_variables.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference_http/native_compilation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference_http/reference.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/rest_based_examples.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/servers.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/stable_structures.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/the_azle_book.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/timers.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/update_methods.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/azle.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/candid.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/canisters_overview.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/cross_canister.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/cycles.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/deployment.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/examples.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/http.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/installation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/internet_computer_overview.html

Large diffs are not rendered by default.

133 changes: 132 additions & 1 deletion the_azle_book/book/print.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/searchindex.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/timers.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
- [Servers](./servers.md)
- [Assets](./assets.md)
- [Authentication](./authentication.md)
- [fetch](./fetch.md)
- [Databases]()
- [fetch]()
- [npm]()
- [Cycles]()
- [Tokens]()
Expand Down
1 change: 1 addition & 0 deletions the_azle_book/src/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ app.listen();

Examples:

- [ckbtc](https://github.com/demergent-labs/azle/tree/main/examples/ckbtc)
- [fetch_ic](https://github.com/demergent-labs/azle/tree/main/examples/fetch_ic)
- [internet_identity](https://github.com/demergent-labs/azle/tree/main/examples/internet_identity)

Expand Down
145 changes: 145 additions & 0 deletions the_azle_book/src/fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# fetch TL;DR

Azle canisters use a custom `fetch` implementation to perform cross-canister calls and to perform HTTPS outcalls.

Here's an example of performing a cross-canister call:

```typescript
import { serialize } from 'azle';
import express from 'express';

const app = express();

app.use(express.json());

app.post('/cross-canister-call', async (req, res) => {
const to: string = req.body.to;
const amount: number = req.body.amount;

const response = await fetch(`icp://dfdal-2uaaa-aaaaa-qaama-cai/transfer`, {
body: serialize({
candidPath: '/token.did',
args: [to, amount]
})
});
const responseJson = await response.json();

res.json(responseJson);
});

app.listen();
```

Keep these important points in mind when performing a cross-canister call:

- Use the `icp://` protocol in the URL
- The `canister id` of the canister that you are calling immediately follows `icp://` in the URL
- The `canister method` that you are calling immediately follows the `canister id` in the URL
- The `candidPath` property of the `body` is the path to the Candid file defining the method signatures of the canister that you are calling. You must obtain this file and copy it into your canister. See the [Assets chapter](./assets.md) for info on copying files into your canister
- The `args` property of the `body` is an array of the arguments that will be passed to the `canister method` that you are calling

Here's an example of performing an HTTPS outcall:

```typescript
import express from 'express';

const app = express();

app.use(express.json());

app.post('/https-outcall', async (_req, res) => {
const response = await fetch(`https://httpbin.org/headers`, {
headers: {
'X-Azle-Request-Key-0': 'X-Azle-Request-Value-0',
'X-Azle-Request-Key-1': 'X-Azle-Request-Value-1',
'X-Azle-Request-Key-2': 'X-Azle-Request-Value-2'
}
});
const responseJson = await response.json();

res.json(responseJson);
});

app.listen();
```

# fetch

Azle has custom `fetch` implementations for clients and canisters.

The client `fetch` is used for authentication, and you can learn more about it in the [Authentication chapter](./authentication.md).

Canister `fetch` is used to perform cross-canister calls and [HTTPS outcalls](https://internetcomputer.org/https-outcalls). There are three main types of calls made with canister `fetch`:

1. [Cross-canister calls to a candid canister](#cross-canister-calls-to-a-candid-canister)
2. [Cross-canister calls to an HTTP canister](#cross-canister-calls-to-an-http-canister)
3. [HTTPS outcalls](#https-outcalls)

## Cross-canister calls to a candid canister

Examples:

- [async_await](https://github.com/demergent-labs/azle/tree/main/examples/async_await)
- [bitcoin](https://github.com/demergent-labs/azle/tree/main/examples/bitcoin)
- [canister](https://github.com/demergent-labs/azle/tree/main/examples/canister)
- [ckbtc](https://github.com/demergent-labs/azle/tree/main/examples/ckbtc)
- [composite_queries](https://github.com/demergent-labs/azle/tree/main/examples/composite_queries)
- [cross_canister_calls](https://github.com/demergent-labs/azle/tree/main/examples/cross_canister_calls)
- [cycles](https://github.com/demergent-labs/azle/tree/main/examples/cycles)
- [func_types](https://github.com/demergent-labs/azle/tree/main/examples/func_types)
- [heartbeat](https://github.com/demergent-labs/azle/tree/main/examples/heartbeat)
- [ic_evm_rpc](https://github.com/demergent-labs/azle/tree/main/examples/ic_evm_rpc)
- [icrc](https://github.com/demergent-labs/azle/tree/main/examples/icrc)
- [ledger_canister](https://github.com/demergent-labs/azle/tree/main/examples/ledger_canister)
- [management_canister](https://github.com/demergent-labs/azle/tree/main/examples/management_canister)
- [threshold_ecdsa](https://github.com/demergent-labs/azle/tree/main/examples/motoko_examples/threshold_ecdsa)
- [whoami](https://github.com/demergent-labs/azle/tree/main/examples/motoko_examples/whoami)
- [recursion](https://github.com/demergent-labs/azle/tree/main/examples/recursion)
- [rejections](https://github.com/demergent-labs/azle/tree/main/examples/rejections)
- [timers](https://github.com/demergent-labs/azle/tree/main/examples/timers)

## Cross-canister calls to an HTTP canister

We are working on better abstractions for these types of calls. For now you would just make a cross-canister call using `icp://` to the `http_request` and `http_request_update` methods of the canister that you are calling.

## HTTPS outcalls

Examples:

- [ethereum_json_rpc](https://github.com/demergent-labs/azle/tree/main/examples/ethereum_json_rpc)
- [http_outcall_fetch](https://github.com/demergent-labs/azle/tree/main/examples/http_outcall_fetch)
- [outgoing_http_requests](https://github.com/demergent-labs/azle/tree/main/examples/outgoing_http_requests)

<!-- // TODO explain that you can generally only do these in POST unless the method is a query method
// TODO we have to show the imports
// TODO explain the POST, PUT, PATCH etc
TODO explain the ic.setOutgoingHttpOptions
TODO split up the examples for each type of fetch
## Canister fetch cross-canister call to a candid canister
Most canisters on ICP are not HTTP canisters. We are pushing to change this situation, but for now this is how things are. Most canisters will thus only expose Candid canister methods.
So imagine a canister that exposes this Candid update method:
```
transfer: (text, text, nat64) -> (nat64);
```
```typescript
const response = await fetch(`icp://dfdal-2uaaa-aaaaa-qaama-cai/transfer`, {
body: serialize({
candidPath: '/src/canister2/index.did',
args: [from, to, amount]
})
});
const responseJson = await response.json();
return responseJson;
```
## Canister fetch cross-canister call to an HTTP canister
## Canister fetch HTTPS outcalls -->

0 comments on commit aaa16c4

Please sign in to comment.