Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 类型promise上不存在属性映射<;无效>;_Angular_Rxjs_Angular6_Rxjs6 - Fatal编程技术网

Angular 类型promise上不存在属性映射<;无效>;

Angular 类型promise上不存在属性映射<;无效>;,angular,rxjs,angular6,rxjs6,Angular,Rxjs,Angular6,Rxjs6,在我的angular 6项目中,我得到的属性映射在promise类型上不存在,即使我包括在内 import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/toPromise'; 下面是我的代码 submit(): Promise<any> { return http.post('api/SubmitEmployee', JSON.string

在我的angular 6项目中,我得到的属性映射在promise类型上不存在,即使我包括在内

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/toPromise';
下面是我的代码

 submit(): Promise<any> {
        return http.post('api/SubmitEmployee', JSON.stringify(this.formData))
            .map((response: Response) => <any>response.json())
            .toPromise()
            .catch(this.handlePromiseError)
    }

    handlePromiseError(error: Response) {
        console.log(error)
    }
包含此项后,将显示错误类型承诺上不存在属性类型 下面是我的自定义
post
方法

post(url: string, content: any, resolve: ResolveFunction = null, reject: RejectFunction = null) {
    this.clearCache();
    const retryFunc = _ => this.post(url, content, resolve, reject);
    return fetch(appSettings.baseApiUri + url, {
      method: 'POST',
      headers: this.getCustomHeader(),
      body: content
    })
      .then(result => {
        this.handleResponse(url, result, retryFunc, resolve, reject);
      })
      .catch(error =>
        this.debounce(_ => this.handleError(url, error, retryFunc).catch(_ => reject(error)), this.debounceTimeout)
      );
  }

使用from来包装http.post-like-from(http.post().then()),它返回一个可观察的,这样你就可以对流进行管道处理使用from来包装http.post-like-from(http.post().then()),它返回一个可观察的,这样你就可以对流进行管道处理带有
pipe
的变量只使用了较新的操作符样式,请参阅:。否则,如果
http.post
返回一个可观察的值,我觉得这很好,所以问题可能在其他地方。如果您使用的是HttpClient,则不需要执行
json()
,因为这是自动执行的。带有
pipe
的变量只使用较新样式的运算符,请参阅:。否则,如果
http.post
返回一个可观察到的值,我觉得这很好,因此问题可能出在其他地方。如果您使用的是HttpClient,则无需执行
json()
,因为这是自动执行的。
post(url: string, content: any, resolve: ResolveFunction = null, reject: RejectFunction = null) {
    this.clearCache();
    const retryFunc = _ => this.post(url, content, resolve, reject);
    return fetch(appSettings.baseApiUri + url, {
      method: 'POST',
      headers: this.getCustomHeader(),
      body: content
    })
      .then(result => {
        this.handleResponse(url, result, retryFunc, resolve, reject);
      })
      .catch(error =>
        this.debounce(_ => this.handleError(url, error, retryFunc).catch(_ => reject(error)), this.debounceTimeout)
      );
  }