我收到以下错误:
DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
在执行GET
对debounce.com的请求时
import{HttpClient} from '@angular/common/http'; export {ThisClass} { constructor(private http:HttpClient){ } validateEmailBounce(email) { const url = 'https://api.debounce.io/v1/?api=my_api_key&email=' + email; console.log(url); // https://api.debounce.io/v1/?api=my_api_key&email=someone@email.com return this.http.get(url); } }
答案 0 :(得分:0)
您可能必须尝试对URL参数进行编码。
const url = 'https://api.debounce.io/v1/?api=my_api_key&email=' + encodeURIComponent(email);
文档: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent