doc: add example requests

This commit is contained in:
KernelDeimos 2024-07-29 20:35:22 -04:00 committed by Eric Dubé
parent c28f2cb4df
commit 7a09c5c47a

View 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());
```