Reputation: 5289
I'm trying to make a simple PUT
call to google sheets API. I followed some of the http.put
syntax, but keep getting the error: this.http.put(...).map is not a function.
My code block:
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());
}
);
Upvotes: 0
Views: 287
Reputation: 222522
Did you import ?
import { map } from 'rxjs/operators';
EDIT
You need to import the above, also i would recommend you to use HttpClient instead of HttpModule which would remove the res.json(), your code will look like,
set the options as,
return this.http.put(url, JSON.stringify(formData), this.options)
.pipe(map(response => response.json()));
Upvotes: 1
Reputation: 9764
Are you using HTTPClient Module?. Here is the Way of Performing PUT method which is similar to POST method.
return this.http.put<Hero>(this.heroesUrl, data, httpOptions)
.pipe(
map(res => {
console.log(res);
return res;
},
catchError(this.handleError('updateHero', hero))
);
Upvotes: 1