我正在尝试调用Web Purify API以检查某些文本中的亵渎行为。
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);
});
}
当我尝试运行该功能时,我一直收到此错误。
No 'Access-Control-Allow-Origin' header is present on the requested resource.
我只需要获取json格式的响应即可检查是否发现了亵渎行为?我是否尝试正确执行此操作?