Commit dec7f0bb authored by Sylvain Kerkour's avatar Sylvain Kerkour

move to fetch and jquery slim

parent 9b685e33
Pipeline #147390348 passed with stages
in 57 seconds
......@@ -61,11 +61,15 @@ function graphqlReq(query, variables) {
variables: variables,
};
var data = {
data : JSON.stringify(payload),
contentType : 'application/json',
type : 'POST',
body : JSON.stringify(payload),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method : 'POST',
};
return $.ajax(window.apiBaseUrl+'/graphql', data);
return fetch(window.apiBaseUrl+'/graphql', data)
.then(function(res) { return res.json() });
}
function subscribeToNewsletter(email) {
......@@ -80,17 +84,17 @@ function subscribeToNewsletter(email) {
},
};
graphqlReq(query, variables)
.done(function(data) {
.then(function(data) {
if (data.errors && data.errors.length > 0) {
displayError(data.errors[0].message);
return ;
}
window.location.href = '/confirm';
})
.fail(function() {
.catch(function() {
displayError('Error subscribing. Please try again.');
})
.always(function() {
.finally(function() {
hideLoader();
})
}
......@@ -114,17 +118,17 @@ function unsubscribe() {
},
};
graphqlReq(query, variables)
.done(function(data) {
.then(function(data) {
if (data.errors && data.errors.length > 0) {
displayError(data.errors[0].message);
return ;
}
displaySuccess('You no longer will receive our emails. Have a good day!');
})
.fail(function() {
.catch(function() {
displayError('Error unsuscribing. Please click again on the link provided in the email.');
})
.always(function() {
.finally(function() {
hideLoader();
})
}
......@@ -181,17 +185,17 @@ $(document).ready(function() {
},
};
graphqlReq(query, variables)
.done(function(data) {
.then(function(data) {
if (data.errors && data.errors.length > 0) {
displayError(data.errors[0].message);
return ;
}
displaySuccess('You are now subscribed to <b>Open Source Weekly</b>');
})
.fail(function() {
.catch(function() {
displayError('Error confirming your subscription. Please click again on the link provided in the email.');
})
.always(function() {
.finally(function() {
hideLoader();
})
}
......
......@@ -14,7 +14,7 @@
{{ partial "footer.html" . }}
</footer>
</body>
<script src="{{ "js/jquery-3.4.1.min.js" | relURL }}"></script>
<script src="{{ "js/jquery-3.5.1.slim.min.js" | relURL }}"></script>
{{ with resources.Get "js/index.js" | minify }}
<script type="text/javascript">{{ .Content | safeJS }}</script>
{{ end }}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment