21 lines
525 B
JavaScript
21 lines
525 B
JavaScript
var cache = cache || {}
|
|
|
|
async function pandoraAPI(action, data) {
|
|
var url = pandoraURL + '/api/'
|
|
//var url = '/pandoraAPI/'
|
|
var key = JSON.stringify([action, data])
|
|
if (!cache[key]) {
|
|
var response = await fetch(url, {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
action: action,
|
|
data: data
|
|
})
|
|
})
|
|
cache[key] = await response.json()
|
|
}
|
|
return cache[key]
|
|
}
|
|
|
|
|