错误:未捕获(在承诺中):状态为响应:URL为0:null

时间:2017-11-10 13:51:49

标签: angular http asp.net-web-api cross-domain response

我正在尝试在localhost上链接前端和后端。 后端在localhost:19993下的ASP.NET Development Server上运行。 在localhost上运行的前端:4200。它是Angular CLI。

在角度我正在使用下面的方法:

private apiUrl = 'http://localhost:19993/api/SearchForm';

getSearchResultTable(hash: string): Promise<Array<ResultTableCardViewModel>> {
         return this.baseService.get<Array<ResultTableCardViewModel>>(this.apiUrl);
}

来自baseService的方法:

public get<T>(url: string, options?: RequestOptionsArgs): Promise<T> {
    return this.http.get(url, options)
        .toPromise()
        .then(response => response.json() as T);
}

但是根据要求我会看到以下错误:

enter image description here

我将proxy.conf.json添加到根文件夹,其中包含以下内容:

{
    "/api": {
      "target": "http://localhost:19993",
      "secure": false
    }
}

也是package.json设置:"start": "ng serve --proxy-config proxy.conf.json"。 但这个问题并没有解决。我做错了什么?

0 个答案:

没有答案
相关问题