TypeError:映射不是函数

bra

我正在尝试对API进行POST调用,并且在标题中收到错误。我已经检查了所有其他相关问题,并确保没有这些问题。我已经导入了rxjsmap运算符。实际上,我在前端Angular 6应用程序中的数百个其他http调用中使用了完全相同的语法,没有问题。

这是导致问题的代码段:

public createMap(map) {
    map.companyId = this.company.getCompanyId();
    const temp = this.json.clone(map);
    temp.settings = this.json.manageJSON(temp.settings, true);

    return this.authHttp.post(environment.coreApiPath + 'importMaps', temp)
        .pipe(map((res: any) => {
            map.ID = res.ID;
            map.tempName = null;
            this.maps.push(map);
            return map;
        }),
        catchError(error => { throw Error('Custom Error: There was an error when attempting to create this import map.') }));
}

错误在读取的行上 .pipe(map((res: any) => {

任何想法可能导致此问题吗?

以防万一,这是我的进口商品:

import { HttpClient } from '@angular/common/http';
import { map, catchError } from 'rxjs/operators';
TJ人群

您的参数map遮盖了您导入的map

import { map, catchError } from 'rxjs/operators';
//       ^^^------------------- import

// ...

public createMap(map) {
//               ^^^----------- parameter

因此,在内部createMap,您不能使用导入的内容map它无法访问。

考虑重命名参数或重命名导入。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章