java - 错误 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);
}
}
请指导一下,谢谢
解决方案
你能检查你的价值environment.CVUrl
吗?我想你错过了,http://
或者https://
如果你把任何 ip 像 '192.168....' 那么你必须使用 environment.CVUrl = ' http://192.168 ....' 希望这会对你有所帮助
推荐阅读
- c# - 关于 xamarin 表单中复杂图表的问题
- javascript - Vuetify 小吃吧有条件
- jquery - jquery获取带有数字的json数据
- javascript - 深入讲解用Javascript将简单数组转换为二维数组(矩阵)
- mysql - MySQL 错误:ReverseEngineerTable:在 LONGCHAR 列上跳过索引 table.column
- c# - 回发后 Web 用户控件上的下拉列表为空
- c++ - 为二叉树编写 remove() 函数
- leaflet - 有没有办法计算传单地图视图中有多少可见标记或标记簇?
- sql-server - 如何遍历每个表中的所有表和字段以获取缺失值的百分比
- r - 在粘贴时更改剪贴板的输出