18 lines
433 B
JavaScript
18 lines
433 B
JavaScript
import debounce from 'debounce'
|
|
|
|
const csrfToken = document.querySelector("[name='csrf-token']").content
|
|
|
|
export function submitValue(url, value) {
|
|
fetch(url, {
|
|
method: 'PUT',
|
|
headers: {
|
|
"x-csrf-token": csrfToken,
|
|
"content-type": "application/json",
|
|
},
|
|
body: JSON.stringify(value),
|
|
})
|
|
}
|
|
|
|
export function submitValueDebounced() {
|
|
return debounce(submitValue, 300)
|
|
}
|