Skip to content

Commit

Permalink
Update HTTP Client Recipe for 2.0 (#2072)
Browse files Browse the repository at this point in the history
* Update HTTP Client Recipe for 2.0

Updates docs for http client recipe to show the 2.0 configuration (scopes are part of permissions)

* Update http-client.mdx

Adds link to ACL page underneath updated configuration.

* fix: fixing indentation for astro

---------

Co-authored-by: Paul Valladares <[email protected]>
  • Loading branch information
WalrusSoup and dreyfus92 authored Apr 17, 2024
1 parent ae03771 commit f974709
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/content/docs/features/http-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,29 @@ The http plugin is available in both as an JavaScript API and in Rust as a [reqw

<Steps>

1. To keep your app safe, configure allowed scope. Read more on [JavaScript API reference](/references/v2/js/http/#security).
1. Configure the allowed URLs

```json
//tauri.conf.json
//src-tauri/capabilities/base.json
{
"plugins": {
"http": {
"scope": ["http://my.api.host/*"]
}
}
"permissions": [
{
"identifier": "http:default",
"allow": [{ "url": "https://*.tauri.app" }],
"deny": [{ "url": "https://private.tauri.app" }]
}
]
}
```
For more information, please see the documentation for [Access Control Lists](/references/v2/acl/)

2. Send a request

```js
import { fetch } from '@tauri-apps/plugin-http';

// Send a GET request
const response = await fetch('http://my.api.host/data.json', {
const response = await fetch('http://test.tauri.app/data.json', {
method: 'GET',
});
console.log(response.status); // e.g. 200
Expand Down

0 comments on commit f974709

Please sign in to comment.