I have this GET in jQuery Ajax and I need to convert it to Fetch. The question I'm having is that cache: false
is the same as cache: "no-store"
in header param in fetch?
Ajax call
function ajaxLogoutDetailsApi() {
$.ajax({
type: "GET",
url: "OIDCGetLogoutDetails",
async: false,
cache: false,
data: "json",
success: function (data, status, xhr) {
data = data.replace('\/\*', '');
data = data.replace('\*\/', '');
var dataJson = JSON.parse(data);
if (dataJson.logoutUrl != null) {
document.location.href = dataJson.logoutUrl;
}
},
error: function (xhr, status, err) {
console.log("error in ajaxLogoutDetailsApi");
}
});
}
Fetch call:
function ajaxLogoutDetailsApi() {
const endpoint = 'OIDCGetLogoutDetails';
fetch(endpoint, {cache: "no-store"})
.then(json => {
const updated = json
.replace('\/\*', '')
.replace('\*\/', '');
const data = JSON.parse(updated);
if (data.logoutUrl) {
window.location.href = data.logoutUrl;
}
})
.catch(error => {
console.error('Error:', error);
});
}