Currently, I am in the process of learning how to develop simple and basic Angular applications. As part of my learning journey, I decided to incorporate my Twitter timeline into one of my projects. To aid me in this endeavor, I referred to various online resources such as YouTube tutorials and blog posts. One particular tutorial that greatly assisted me was titled - Connect to the Twitter API in an Angular 6 App. Following these guidelines, I successfully created a rudimentary Angular-Twitter application. Below, you can find snippets of the code:
server.js (no issues with this segment)
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);
});
});
Subsequently, I formulated twitterservice.service.ts (concerns encountered within this block of 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 ...
}
}
Encountering an error during the usage of the map
method:
Property 'map' does not exist on type 'TwitterserviceService'.
Despite the successful operation of my server.js, verified through testing via Postman
resulting in the desired JSON output, I have searched extensively for solutions online. I came across articles and related questions like: Property 'map' does not exist on type 'Observable'. However, I am yet to resolve this issue. Seeking guidance for rectification, any help provided would be greatly appreciated.