Skip to content

Commit 0d51d7c

Browse files
committed
Default accept/content-type headers for requests
License: MIT Signed-off-by: Victor Bjelkholm <git@victor.earth>
1 parent 3e94262 commit 0d51d7c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ui.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@
429429

430430
async function init() {
431431
log('[init]')
432+
433+
console.log('checking env, ', current_env)
434+
if (current_env === 'dev') {
435+
console.log('Im in dev, change colors yo')
436+
$toggleMenuIcon.style.backgroundColor = 'yellow'
437+
}
438+
432439
frameNotSelected()
433440
const res = await postAndWaitForReply('load-parameter', {key: "api_key"})
434441
const api_key = res.value
@@ -450,12 +457,6 @@
450457
updateWebsiteID()
451458

452459
$checkAuthenticated.checked = checkAuthenticated
453-
454-
if (current_env === 'dev') {
455-
console.log('Im in dev, change colors yo')
456-
$toggleMenuIcon.style.backgroundColor = 'yellow'
457-
}
458-
459460
}
460461

461462
init()
@@ -509,7 +510,11 @@
509510
async function call(url, opts, decode) {
510511
log($api_key.value || default_api_key)
511512
api_key_to_use = shouldUseApiKey() ? $api_key.value : default_api_key
512-
let defaultHeaders = {"Authorization": "Token " + api_key_to_use}
513+
let defaultHeaders = {
514+
"Authorization": "Token " + api_key_to_use,
515+
"Accept": "application/json",
516+
"Content-Type": "application/json"
517+
}
513518
if (opts.headers) {
514519
opts.headers = Object.assign({}, opts.headers, defaultHeaders)
515520
}

0 commit comments

Comments
 (0)