mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
doc: add example requests
This commit is contained in:
parent
c28f2cb4df
commit
7a09c5c47a
36
src/backend/src/modules/test-drivers/doc/requests.md
Normal file
36
src/backend/src/modules/test-drivers/doc/requests.md
Normal file
@ -0,0 +1,36 @@
|
||||
```javascript
|
||||
blob = await (await fetch("http://api.puter.localhost:4100/drivers/call", {
|
||||
"headers": {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${puter.authToken}`,
|
||||
},
|
||||
"body": JSON.stringify({
|
||||
interface: 'test-image',
|
||||
method: 'get_image',
|
||||
args: {
|
||||
source_type: 'string:url:web'
|
||||
}
|
||||
}),
|
||||
"method": "POST",
|
||||
})).blob();
|
||||
dataurl = await new Promise((y, n) => {
|
||||
a = new FileReader();
|
||||
a.onload = _ => y(a.result);
|
||||
a.onerror = _ => n(a.error);
|
||||
a.readAsDataURL(blob)
|
||||
});
|
||||
URL.createObjectURL(await (await fetch("http://api.puter.localhost:4100/drivers/call", {
|
||||
"headers": {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${puter.authToken}`,
|
||||
},
|
||||
"body": JSON.stringify({
|
||||
interface: 'test-image',
|
||||
method: 'echo_image',
|
||||
args: {
|
||||
source: dataurl,
|
||||
}
|
||||
}),
|
||||
"method": "POST",
|
||||
})).blob());
|
||||
```
|
Loading…
Reference in New Issue
Block a user