File: browser-test.html

package info (click to toggle)
node-solid-rest 1.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 420 kB
  • sloc: javascript: 529; sh: 31; makefile: 15
file content (29 lines) | stat: -rw-r--r-- 869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script src="../src/localStorage.js"></script>
<script src="../dist/main.js"></script>
<div id="results"></div>
<script>

runStorage( "/test-folder/test-file.ttl","<> a <#test>." ).then( ()=>{
  runRest( "/test-folder/test-file.ttl","<> a <#test>." )
})

async function runStorage(file,text){
  const storage = new SolidLocalStorage()
  let response = await storage.putResource( file,{body:text} )
  response = await storage.getResource( file )
  show(await response)
}
async function runRest(file,text){
  const rest = new SolidRest( new SolidLocalStorage() )
  show(rest.storage.name)
  let response = await rest.fetch( file,{method:"PUT",body:text} )
  response = await rest.fetch( file )
  show(await response.text())
}
function show(msg){
  let display = document.getElementById("results")
  display.innerHTML = display.innerHTML + `<p>${msg}</p>`  
}
</script>