Use GWS with JavaScript
The experimental project gplates-js is a good example of how the GPlates Web Service can be used with JavaScript.
Use the fetch API
<!DOCTYPE html><html><body><script async>(async () => {const response = await fetch("https://gws.gplates.org/reconstruct/coastlines/?time=50&model=muller2019")if (!response.ok) {throw new Error(`Response status: ${response.status}`);} else {document.write(await response.text());}})();</script></body></html>
Use the XMLHttpRequest object
var url = 'https://gws.gplates.org/reconstruct/coastlines/?time=50';var method = "GET"var xhr = new XMLHttpRequest();if("withCredentials" in xhr){xhr.open(method, url, true);}else if(typeof XDomainRequest != "undefined"){xhr = new XDomainRequest();xhr.open(method, url);}else{xhr = null;}if (!xhr) {throw new Error('Does your web browser support CORS?');}xhr.onload = function() {var text = xhr.responseText;console.log(text);};xhr.onerror = function() {alert('something is wrong!');};xhr.send();
Alternatively, you can also choose to use jQuery, Axios, etc.