Update API
parent
75b6118b9f
commit
73ff9f871d
1 changed files with 29 additions and 15 deletions
44
API.md
44
API.md
|
@ -61,23 +61,37 @@ var_dump($result);
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<script>
|
||||||
function pandora_api(action, data, callback) {
|
async function api(action, data) {
|
||||||
var url = 'http://archive.arabdigitalexpression.org/api/';
|
const url = "https://pad.ma/api/"
|
||||||
var xhr = new XMLHttpRequest();
|
var response = await fetch(url, {
|
||||||
xhr.addEventListener('load', function (evt) {
|
method: 'POST',
|
||||||
var data = JSON.parse(evt.target.responseText);
|
headers: {
|
||||||
callback(data);
|
'Content-Type': 'application/json'
|
||||||
});
|
},
|
||||||
var formData = new FormData();
|
body: JSON.stringify({
|
||||||
formData.append('action', action);
|
action: action,
|
||||||
formData.append('data', JSON.stringify(data));
|
data: data
|
||||||
xhr.open('POST', url);
|
})
|
||||||
xhr.send(formData);
|
})
|
||||||
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora_api('find', {query: ....}, function(result) {
|
|
||||||
console.log(result)
|
api('find', {
|
||||||
});
|
query: {
|
||||||
|
conditions: [
|
||||||
|
{key: 'title', operator: '=', value: 'A Day'}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
keys: ['id', 'title', 'summary'],
|
||||||
|
range: [0, 10]
|
||||||
|
}).then(result => {
|
||||||
|
result.data.items.forEach(item => {
|
||||||
|
const div = document.createElement("div")
|
||||||
|
div.innerHTML = `<h1><a href="https://pad.ma/${item.id}">${item.title}</a></h1><p>${item.summary}</p>`
|
||||||
|
document.body.appendChild(div)
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in a new issue