I am attempting to make a call to the Web Purify API to check profanity in certain text.
function webPurifyAPi(string){
const Http = new XMLHttpRequest();
const url="http://www.webpurify.com/services/rest/?method=webpurify.live.check&api_key=apiKEY&lang=en&format=json&text="+string;
Http.open("GET",url);
Http.send();
Http.onreadystatechange=(e)=>{
console.log(this.responseText);
}
fetch(url).then(response => response.json()).then(data => {
if(data.error_messages) {
throw new Error(data.error_message);
}
console.log(data);
});
}
I keep getting this error when I attempt to run the function.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
I need to just get the response in json format to check if profanity is found? Am I attempting to do this correctly?