Browse Source

client side js

master
bake 1 year ago
parent
commit
fbee4bccb7
2 changed files with 16 additions and 0 deletions
  1. 1
    0
      server/public/index.html
  2. 15
    0
      server/public/js/index.js

+ 1
- 0
server/public/index.html View File

@@ -0,0 +1 @@
<script src="/assets/js/index.js"></script>

+ 15
- 0
server/public/js/index.js View File

@@ -0,0 +1,15 @@
const createJob = (url, name, browser = 'firefox', width = 1280) => {
const title = `${new URL(url).host} - ${name} - ${browser}`
return fetch('/api/job', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'screenshot',
data: { title, url, name, browser, width },
}),
}).then(res => res.json())
}

createJob('https://www.example.com/', 'home', 'chrome')
.then(console.log)
.catch(console.error)

Loading…
Cancel
Save