Error: No 'map' property found in 'TwitterserviceService' type

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.

Answer №1

Substitute this.map with just map. By using the keyword this, it suggests that map is a variable belonging to the 'TwitterserviceService' service.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps can be taken to ensure a successful request to a Node.js server when previewing an Angular app on a separate device within the same network?

My desktop computer hosts the Angular front-end on port 4200 and the Express.js back-end on port 4000. When I try to access the Angular app from my mobile Android phone using 192.168.1.X:4200, the app loads but doesn't display any data from the Expres ...

Is it possible to globally define a namespace in Typescript?

Seeking a way to make my Input module accessible globally without the need for explicit path definitions. Currently, I have to import it like this: import { Input } from "./Input/Input";. Is there a method to simplify the import statement for modules con ...

Angular Material's *matNoDataRow directive is malfunctioning

I am having an issue with using the *matNoDataRow directive in Angular Material. I have created a MatTable with filtering functionality, and when no data matches the filter, I want to display a specific text. However, the directive does not seem to be work ...

Angular - The Architectural Design of Components

I am looking to create a component that can serve as a template for multiple components, all sharing the same methods. How can I convert this into a blueprint? My goal is to avoid duplicating methods across all other components. Instead, I only want to ov ...

Conditional type in Typescript can be used to infer tuple types

Why are output1 and output2 not both inferred as [number, number, number] in the following code snippets? Snippet 1 : type InferTuple1<T> = T extends any[] ? [...T]: never; const func1 = <T>(t: InferTuple1<T>) => t; const output1 = ...

Issue with PrimeNG autocomplete dropdown. It only functions correctly upon initial use

Environment Info: NODE Version: 8.12.0 Angular Version: 7.3.4 PrimeNG Version : 7.0.0 I have integrated the dropdown feature of PrimeNG's autocomplete component into my application. The issue I am facing is that the dropdown only loads for the ...

Is it necessary to retrieve the data that was posted from the back-end? Implementation using Angular and Node.js

I need some advice on how to handle worker data in my Angular, NodeJS, and MySQL app. In the FORM, users can add workers whose information is then sent to the backend for processing. The user can preview the posted information and delete workers if needed. ...

Error occurs when a value is passed to a component after it has already been checked for changes

Whenever I try to pass a value as input to a custom child component, I keep encountering the error message indicating that the expression has changed after being checked. The structure of the child component is as follows: <mat-card *ngIf="user$ | asyn ...

What are the steps for implementing angular DataTable?

Currently working with Angular 6 and trying to implement an Angular data table, but encountering the following error. Need assistance in resolving this issue and implementing the Angular data table successfully. Encountering the error shown below: ERROR ...

Having issues with implementing PrimeNG components (Directive annotation not detected)

Having difficulty integrating PrimeNG components (beta5) with Angular2 (rc.1). Whenever attempting to utilize a component, such as the menubar, the following error is consistently encountered: No Directive annotation found on Menubar New to Angular and ...

Dynamically incorporating validation to an ngModel input

Utilizing NgForm, I dynamically added a validator to the input field. In my first example, everything works perfectly when I use the button setValidation to validate the input. However, in the second example where I add formGroup, I encounter an error whe ...

Issue with bundling project arises post upgrading node version from v6.10 to v10.x

My project uses webpack 2 and awesome-typescript-loader for bundling in nodejs. Recently, I upgraded my node version from 6.10 to 10.16. However, after bundling the project, I encountered a Runtime.ImportModuleError: Error: Cannot find module 'config ...

React Project Encounters NPM Installation Failure

I recently started delving into the world of React and experimenting with different examples. Everything was running smoothly until I attempted to start the server [npm start] and encountered an error as shown below. Despite my best efforts, I can't p ...

Counting up in Angular from a starting number of seconds on a timer

Is there a way to create a countup timer in Angular starting from a specific number of seconds? Also, I would like the format to be displayed as hh:mm:ss if possible. I attempted to accomplish this by utilizing the getAlarmDuration function within the tem ...

Don't display div if database has certain value - Angular

Is there a way to determine if a specific value exists in a PostgreSQL database? If so, can I then hide an HTML element based on this information? Can CSS and JavaScript be used to hide elements, or is there another method that should be utilized for hidi ...

The process of upgrading all dependencies to a particular version

I need guidance on upgrading a project from Angular 6 to version 7. The challenge lies in updating numerous dependencies as well. Most tutorials available only cover upgrading to the latest version (v8), rather than a specific one. Can anyone provide ins ...

RxJS pipe operation ignoring observable

Currently, I am in the process of transitioning an app from Promises to RxJS and I could use some guidance on whether I am heading in the right direction. Situation: I have a ModalComponent that appears when an HTTP request is sent and disappears once the ...

To set up the store in configureStore, you must provide one type argument for the 'MakeStore' generic type

Encountering an issue with MakeStore showing a Generic type error 'MakeStore' requires 1 type argument(s) .ts(2314) Here is the code from configureStore.ts: import { configureStore, EnhancedStore, getDefaultMiddleware, } from '@reduxj ...

Storing data retrieved from MongoDB into a local array in a MEAN stack

I am currently working on a small application using the MEAN stack. I have saved some user details in MongoDB and now I want to retrieve and store only the email ids in a local array. The fetching part is working well, but I'm facing issues with savin ...

Creating unique components with Angular2 and Ionic

Here is the HTML code for my custom component: <div> {{text}} {{percentLeft}} {{innerColor}} </div> And here is the TypeScript file for my component: import { Component, Input } from '@angular/core'; @Component({ selector: ...