首页 > 解决方案 > 错误 DOMException:无法在“XMLHttpRequest”上执行“打开”:无效的 URL

问题描述

我正在使用一个运行良好的数据库,但是当我想在表格中显示我的信息时出现错误。

我收到以下错误:

 ERROR DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
    at http://localhost:4200/polyfills.js:6202:31
    at XMLHttpRequest.proto.<computed> [as open] (http://localhost:4200/polyfills.js:4663:24)

我的服务等级:

     import { Injectable } from '@angular/core';
     import { HttpClient, HttpHeaders } from '@angular/common/http';

     import {Certificaten} from "../certificaten";
     import {Observable} from "rxjs";
     import {environment} from "../../../environments/environment";

     @Injectable({
     providedIn: 'root'
      })
     export class CertificatenService {

     private certificatenUrl: string;

     constructor(private http: HttpClient) {
      }

     public findAll(): Observable<Certificaten[]> {
     return this.http.get<Certificaten[]>(`${environment.CVUrl}certificaten`);
     }
     public save(certificaten: Certificaten) {
     return this.http.post<Certificaten>(this.certificatenUrl, Certificaten);
      }

       }

请指导一下,谢谢

标签: javamysqlangulardatabase

解决方案


你能检查你的价值environment.CVUrl吗?我想你错过了,http://或者https://如果你把任何 ip 像 '192.168....' 那么你必须使用 environment.CVUrl = ' http://192.168 ....' 希望这会对你有所帮助


推荐阅读