fix: include cookies for fetch request
This commit is contained in:
parent
229d04eb07
commit
0a667b312d
6 changed files with 75 additions and 34 deletions
|
@ -3,7 +3,8 @@ $(function() {
|
||||||
* Statistics
|
* Statistics
|
||||||
*/
|
*/
|
||||||
fetch('/index.php?page=api&module=statistics&table=all', {
|
fetch('/index.php?page=api&module=statistics&table=all', {
|
||||||
method: 'GET'
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -57,7 +58,8 @@ $(function() {
|
||||||
* News
|
* News
|
||||||
*/
|
*/
|
||||||
fetch('/index.php?page=api&module=blog', {
|
fetch('/index.php?page=api&module=blog', {
|
||||||
method: 'GET'
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
|
|
@ -21,8 +21,9 @@ window.addEventListener("load", (event) => {
|
||||||
|
|
||||||
/** Save page preview */
|
/** Save page preview */
|
||||||
fetch('/index.php?page=api&module=save-preview', {
|
fetch('/index.php?page=api&module=save-preview', {
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
body : data
|
credentials : 'include',
|
||||||
|
body : data,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
|
|
@ -10,8 +10,9 @@ $(function() {
|
||||||
form.addClass('loading');
|
form.addClass('loading');
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=database-test', {
|
fetch('/index.php?page=api&module=database-test', {
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
body : formDatabase
|
credentials : 'include',
|
||||||
|
body : formDatabase,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
|
|
@ -93,7 +93,13 @@ $(function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
fetch('/index.php?' + get_wish, { method: 'GET' })
|
fetch(
|
||||||
|
'/index.php?' + get_wish,
|
||||||
|
{
|
||||||
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
|
}
|
||||||
|
)
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
|
@ -110,7 +116,13 @@ $(function () {
|
||||||
var wish_image_ext = wish_image.split('.').pop();
|
var wish_image_ext = wish_image.split('.').pop();
|
||||||
|
|
||||||
if ('svg' === wish_image_ext) {
|
if ('svg' === wish_image_ext) {
|
||||||
fetch(wish_image, { method: 'GET' })
|
fetch(
|
||||||
|
wish_image,
|
||||||
|
{
|
||||||
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
|
}
|
||||||
|
)
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
|
@ -138,8 +150,9 @@ $(function () {
|
||||||
$(document).on('click', wish_button_mark_as_fulfilled, function() {
|
$(document).on('click', wish_button_mark_as_fulfilled, function() {
|
||||||
const modal_wish_details = $(this).closest('.ui.modal');
|
const modal_wish_details = $(this).closest('.ui.modal');
|
||||||
const mark_as_fulfilled = {
|
const mark_as_fulfilled = {
|
||||||
'method' : 'PUT',
|
'method' : 'PUT',
|
||||||
'body' : new URLSearchParams({
|
'credentials' : 'include',
|
||||||
|
'body' : new URLSearchParams({
|
||||||
'wish_id' : wish.id,
|
'wish_id' : wish.id,
|
||||||
'wish_status' : wishthis.wish.status.fulfilled,
|
'wish_status' : wishthis.wish.status.fulfilled,
|
||||||
}),
|
}),
|
||||||
|
@ -168,8 +181,9 @@ $(function () {
|
||||||
$(document).on('click', wish_button_fulfil_wish, function() {
|
$(document).on('click', wish_button_fulfil_wish, function() {
|
||||||
const modal_wish_details = $(this).closest('.ui.modal');
|
const modal_wish_details = $(this).closest('.ui.modal');
|
||||||
const mark_as_fulfilled = {
|
const mark_as_fulfilled = {
|
||||||
'method' : 'PUT',
|
'method' : 'PUT',
|
||||||
'body' : new URLSearchParams({
|
'credentials' : 'include',
|
||||||
|
'body' : new URLSearchParams({
|
||||||
'wish_id' : wish.id,
|
'wish_id' : wish.id,
|
||||||
'wish_status' : wishthis.wish.status.unavailable,
|
'wish_status' : wishthis.wish.status.unavailable,
|
||||||
}),
|
}),
|
||||||
|
@ -278,8 +292,9 @@ $(function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishes', {
|
fetch('/index.php?page=api&module=wishes', {
|
||||||
'method' : 'POST',
|
'method' : 'POST',
|
||||||
'body' : wish_data,
|
'credentials' : 'include',
|
||||||
|
'body' : wish_data,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -336,8 +351,9 @@ $(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishes', {
|
fetch('/index.php?page=api&module=wishes', {
|
||||||
'method' : 'DELETE',
|
'method' : 'DELETE',
|
||||||
'body' : wish_delete,
|
'credentials' : 'include',
|
||||||
|
'body' : wish_delete,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
|
|
@ -142,8 +142,9 @@ $(function () {
|
||||||
formData.append('wishlist_id', wishthis.$_GET.id);
|
formData.append('wishlist_id', wishthis.$_GET.id);
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishlists', {
|
fetch('/index.php?page=api&module=wishlists', {
|
||||||
method : 'PUT',
|
method : 'PUT',
|
||||||
body : formData,
|
credentials : 'include',
|
||||||
|
body : formData,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -224,8 +225,9 @@ $(function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
fetch('/index.php?page=api&module=wishlists', {
|
fetch('/index.php?page=api&module=wishlists', {
|
||||||
'method' : 'DELETE',
|
'method' : 'DELETE',
|
||||||
'body' : delete_wishlist,
|
'credentials' : 'include',
|
||||||
|
'body' : delete_wishlist,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -331,8 +333,9 @@ $(function () {
|
||||||
var formData = new URLSearchParams(new FormData(formWishlistCreate[0]));
|
var formData = new URLSearchParams(new FormData(formWishlistCreate[0]));
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishlists', {
|
fetch('/index.php?page=api&module=wishlists', {
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
body : formData
|
credentials : 'include',
|
||||||
|
body : formData
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -395,7 +398,8 @@ $(function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
fetch('/index.php?' + params_url, {
|
fetch('/index.php?' + params_url, {
|
||||||
method: 'GET'
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -432,8 +436,9 @@ $(function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishes', {
|
fetch('/index.php?page=api&module=wishes', {
|
||||||
method : 'PUT',
|
method : 'PUT',
|
||||||
body : formData
|
credentials : 'include',
|
||||||
|
body : formData
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -468,8 +473,9 @@ $(function () {
|
||||||
formData.append('wishlist_id', wishthis.$_GET.id);
|
formData.append('wishlist_id', wishthis.$_GET.id);
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishes', {
|
fetch('/index.php?page=api&module=wishes', {
|
||||||
'method' : 'POST',
|
'method' : 'POST',
|
||||||
'body' : formData,
|
'credentials' : 'include',
|
||||||
|
'body' : formData,
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -495,7 +501,13 @@ $(function () {
|
||||||
* Update URL
|
* Update URL
|
||||||
*/
|
*/
|
||||||
function updateURL() {
|
function updateURL() {
|
||||||
fetch('/index.php?page=api&module=url&url=' + window.btoa('/?' + urlParams.toString()), { method: 'GET' })
|
fetch(
|
||||||
|
'/index.php?page=api&module=url&url=' + window.btoa('/?' + urlParams.toString()),
|
||||||
|
{
|
||||||
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
|
}
|
||||||
|
)
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
|
|
|
@ -38,7 +38,13 @@ $(function() {
|
||||||
if (!wishlist && wishthis.$_GET.hash) {
|
if (!wishlist && wishthis.$_GET.hash) {
|
||||||
var wishlistId = $('.wishlist-cards[data-wishlist]').attr('data-wishlist');
|
var wishlistId = $('.wishlist-cards[data-wishlist]').attr('data-wishlist');
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishlists&id=' + wishlistId, { method: 'GET' })
|
fetch(
|
||||||
|
'/index.php?page=api&module=wishlists&id=' + wishlistId,
|
||||||
|
{
|
||||||
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
|
}
|
||||||
|
)
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
|
@ -105,8 +111,9 @@ $(function() {
|
||||||
);
|
);
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishlists-saved', {
|
fetch('/index.php?page=api&module=wishlists-saved', {
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
body : formData
|
credentials : 'include',
|
||||||
|
body : formData
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -128,7 +135,8 @@ $(function() {
|
||||||
|
|
||||||
/** Determine if list is saved */
|
/** Determine if list is saved */
|
||||||
fetch('/index.php?page=api&module=wishlists-saved', {
|
fetch('/index.php?page=api&module=wishlists-saved', {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
|
credentials : 'include',
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
@ -176,8 +184,9 @@ $(function() {
|
||||||
buttonRequest.addClass('disabled loading');
|
buttonRequest.addClass('disabled loading');
|
||||||
|
|
||||||
fetch('/index.php?page=api&module=wishlists', {
|
fetch('/index.php?page=api&module=wishlists', {
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
body : formData
|
credentials : 'include',
|
||||||
|
body : formData
|
||||||
})
|
})
|
||||||
.then(handleFetchError)
|
.then(handleFetchError)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
|
|
Loading…
Reference in a new issue