include credentials on fetch calls
This commit is contained in:
parent
4e039fb583
commit
c649dbbcc2
3 changed files with 11 additions and 4 deletions
|
|
@ -3,7 +3,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const createPlanModal = document.getElementById('create-plan-modal');
|
const createPlanModal = document.getElementById('create-plan-modal');
|
||||||
|
|
||||||
async function loadTexts() {
|
async function loadTexts() {
|
||||||
const response = await fetch('/api/texts');
|
const response = await fetch('/api/texts', {
|
||||||
|
credentials: 'same-origin',
|
||||||
|
});
|
||||||
const texts = await response.json();
|
const texts = await response.json();
|
||||||
textsList.innerHTML = texts
|
textsList.innerHTML = texts
|
||||||
.map(text =>
|
.map(text =>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const textId = window.location.pathname.split('/').pop();
|
const textId = window.location.pathname.split('/').pop();
|
||||||
|
|
||||||
fetch('/api/texts/' + textId)
|
fetch('/api/texts/' + textId, { credentials: 'same-origin' })
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(text => {
|
.then(text => {
|
||||||
const h1 = document.createElement('h1');
|
const h1 = document.createElement('h1');
|
||||||
|
|
@ -13,7 +13,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function fetchAndRenderNodes(textId) {
|
function fetchAndRenderNodes(textId) {
|
||||||
return fetch('/api/nodes/' + textId)
|
return fetch('/api/nodes/' + textId, { credentials: 'same-origin' })
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(nodes => {
|
.then(nodes => {
|
||||||
const existing = document.querySelector('#text-detail > ul');
|
const existing = document.querySelector('#text-detail > ul');
|
||||||
|
|
@ -113,6 +113,7 @@ function toggleAddForm(li, parentNodeId, textId) {
|
||||||
fetch('/api/nodes', {
|
fetch('/api/nodes', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'same-origin',
|
||||||
body: JSON.stringify({ textId: parseInt(textId), title, parentNodeId }),
|
body: JSON.stringify({ textId: parseInt(textId), title, parentNodeId }),
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|
@ -157,6 +158,7 @@ function toggleBulkAddForm(li, parentNodeId, textId) {
|
||||||
fetch('/api/nodes/bulk', {
|
fetch('/api/nodes/bulk', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'same-origin',
|
||||||
body: JSON.stringify({ textId: parseInt(textId), parentNodeId, titlePrefix, count }),
|
body: JSON.stringify({ textId: parseInt(textId), parentNodeId, titlePrefix, count }),
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const form = document.getElementById('texts-form');
|
const form = document.getElementById('texts-form');
|
||||||
|
|
||||||
async function loadTexts() {
|
async function loadTexts() {
|
||||||
const res = await fetch('/api/texts');
|
const res = await fetch('/api/texts', {
|
||||||
|
credentials: 'same-origin',
|
||||||
|
});
|
||||||
const texts = await res.json();
|
const texts = await res.json();
|
||||||
textsList.innerHTML = texts.map(text =>
|
textsList.innerHTML = texts.map(text =>
|
||||||
'<li><a href=/admin/texts/'
|
'<li><a href=/admin/texts/'
|
||||||
|
|
@ -18,6 +20,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
const formData = new FormData(form);
|
const formData = new FormData(form);
|
||||||
const res = await fetch('/api/texts', {
|
const res = await fetch('/api/texts', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'same-origin',
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue