I'm learning to create very simple and basic angular applications. I've decided to show my tweets from my twitter timeline. I followed some youtube tutorials and some blogs. Specially this- Connect to the Twitter API in an Angular 6 App. I was able to create a basic working angular-twiiter app (a made up name). I'll show you my code:
server.js (nothing wrong with this code)
const express = require('express');
const Twitter = require('twit');
const app = express();
app.listen(3000, () => console.log('Server running'));
const api_client = new Twitter({
consumer_key: 'MY_KEY',
consumer_secret: 'MY_SECRET_KEY',
access_token: 'MY_TOKEN',
access_token_secret: 'MY_SECRET_TOKEN'
})
app.get('/home_timeline', (req, res) => {
const params = { tweet_mode: 'extended', count: 10 };
api_client
.get('statuses/home_timeline', params)
.then(timeline => {
res.send(timeline);
})
.catch(error => {
res.send(error);
});
});
Then I created twitterservice.service.ts (error in this code)
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class TwitterserviceService {
api_url = 'https:/localhost:3000';
constructor(private http: HttpClient) { }
getTimeline() {
return this.http
.get<any[]>(this.api_url+'/home_timeline')
.pipe(this.map(data => data)); //ERROR: Property 'map' does not exist ...
}
}
For map
I'm getting:
Property 'map' does not exist on type 'TwitterserviceService'.
However, My server.js is working absolutely fine. I've tested it on Postman
and I'm getting the desired JSON output. I tried finding help on the internet, read some articles and questions like: Property 'map' does not exist on type 'Observable'. But still I'm not able to solve this. Please correct me.