Ionic list refresh after deleting an item

Hello everyone,

im trying to fetch data asychronisouly twitter rest api (fetching my tweets to be more specific), and after i do so, i display them as cards. My problem is when i delete a tweet, it does not reflect in my application.

heres a part of my code:

Twitter service provider.

fetchDataFromTwitter() {
    return this.httpReader = this.http.get('url').map((resp) => resp).catch((err: any) => {
      console.log("error" + err);
      return Observable.of(undefined);

twitterList page

public dataFromTwitter:any;
ionViewDidLoad() {
    this.tweetProvider.fetchDataFromTwitter().subscribe((data: any) => {
 some string manuplation..
          placeOfId: tweet.full_text.slice(indexStart, indexEnd),
          userId: tweet.full_text.slice(indexStartForToken,indexEndForToken)

in the view for twitterList.html page

<ion-content padding>
  <div *ngIf="dataFromTwitter">
  <ion-card *ngFor="let data of dataFromTwitter">
      <ion-icon name="medkit" item-start large></ion-icon>
      <h2 >user: {{data .placeOfId }}</h2>

    <p>token: {{data.userId}}</p>

the example might have errors but, but i hope the idea is clear.

hope any could suggest/help with this problem.

My problem is that I can’t seem to find where you posted the code that does this.

A wild guess (emphasis on wild…and guess) is that you are splicing / slicing / dicing with an erroneous value.

You’re probably leaving a good deal out for the sake of brevity, but as @rapropos said, there’s not near enough context to form any worthwhile opinion

not necessarily deleting a tweet, but even adding a tweet too. since the app is based on multiple user, if another user adds a tweet, it should refresh automatically an the other user should see that tweet that was added.

this is my add tweet function

  addTweet(user) {
    let replyApiUrl = 'url';
      return new Promise((resolve, reject) => {,user)
          .subscribe(res => {
            console.log("im in res"+res)
          }, (err) => {
            console.log("this error:"+ JSON.stringify(err))

I don’t see it adding anything anywhere. All I see it doing is creating and returning an extraneous Promise, although the function signature doesn’t even tell us it’s going to do so.

sorry for not being very clear, i am doing a POST request to my google cloud functions and i also pass the user details that will be added in the tweet. So my code in cloud functions is basically resposible for adding the new tweet.

the cloud functions response is just a string that user was added not much to it.

I can see two options:

(a) every time you POST an addition or deletion, you also emit off a local Observable in the tweet provider reflecting that change, so you are basically keeping up a local shadow copy of the data backing your list, or;

(b) every time you have completed a POST for an addition or deletion, you go back and ask the outside world for a new copy of the data backing your list.

If I as a reader can’t tell that addTweet() is intended to modify dataFromTwitter somehow, then I can’t see how dataFromTwitter is ever going to get that message either.