Google Sheet API, PUT: this.http.put(...).map 不是函数
Google Sheet API, PUT: this.http.put(...).map is not a function
我正在尝试对 google 张 API 进行简单的 PUT
调用。我遵循了一些 http.put
语法,但不断收到错误消息:this.http.put(...).map is not a function.
我的代码块:
return this.http
.put(url, JSON.stringify(data), {headers: headers})
.map(
(res: any) => {
res.json();
console.log ("transaction data updated to google seets:"+res.json());
}
);
您在使用 HTTPClient 模块吗?。这是类似于POST方法的PUT方法的执行方式。
return this.http.put<Hero>(this.heroesUrl, data, httpOptions)
.pipe(
map(res => {
console.log(res);
return res;
},
catchError(this.handleError('updateHero', hero))
);
你导入了吗?
import { map } from 'rxjs/operators';
编辑
您需要导入以上内容,我还建议您使用 HttpClient 而不是 HttpModule,后者会删除 res.json(),您的代码将如下所示,
将选项设置为,
return this.http.put(url, JSON.stringify(formData), this.options)
.pipe(map(response => response.json()));
我正在尝试对 google 张 API 进行简单的 PUT
调用。我遵循了一些 http.put
语法,但不断收到错误消息:this.http.put(...).map is not a function.
我的代码块:
return this.http
.put(url, JSON.stringify(data), {headers: headers})
.map(
(res: any) => {
res.json();
console.log ("transaction data updated to google seets:"+res.json());
}
);
您在使用 HTTPClient 模块吗?。这是类似于POST方法的PUT方法的执行方式。
return this.http.put<Hero>(this.heroesUrl, data, httpOptions)
.pipe(
map(res => {
console.log(res);
return res;
},
catchError(this.handleError('updateHero', hero))
);
你导入了吗?
import { map } from 'rxjs/operators';
编辑
您需要导入以上内容,我还建议您使用 HttpClient 而不是 HttpModule,后者会删除 res.json(),您的代码将如下所示,
将选项设置为,
return this.http.put(url, JSON.stringify(formData), this.options)
.pipe(map(response => response.json()));