Browse Source

client side js

master
bake 9 months 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 @@
1
+<script src="/assets/js/index.js"></script>

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

@@ -0,0 +1,15 @@
1
+const createJob = (url, name, browser = 'firefox', width = 1280) => {
2
+	const title = `${new URL(url).host} - ${name} - ${browser}`
3
+	return fetch('/api/job', {
4
+		method: 'POST',
5
+		headers: { 'Content-Type': 'application/json' },
6
+		body: JSON.stringify({
7
+			type: 'screenshot',
8
+			data: { title, url, name, browser, width },
9
+		}),
10
+	}).then(res => res.json())
11
+}
12
+
13
+createJob('https://www.example.com/', 'home', 'chrome')
14
+	.then(console.log)
15
+	.catch(console.error)

Loading…
Cancel
Save