0

I am facing one issue. In my application my page is requesting to server which is run by Node.js to fetch 2000 record at a time. Here the records are coming from Node but in dev tool console its not expanding and also I have some loader implementation that is not stopping even after receiving the response. I am explaining whole code below.

demo.component.ts:

onFileSelect($event) {
    const file = $event.target.files[0];
    const fileName = file.name;
    const fileExtension = fileName.replace(/^.*\./, '');
    if (fileExtension === 'ubot') {
      this.loginService.startSpinner(true);
      const formData = new FormData();
      formData.append('cec', this.cec);
      formData.append('screenName', this.intFlow);
      formData.append('fileCategory', 'payload');
      formData.append('file', file);
      this.intentService.reverseFile(formData).subscribe(async (res: any) => {
        console.log('response', res);
        console.log('succ', res.status);
        if (res && res.status === 'success') {
          this.loginService.startSpinner(false);
          this.intentService.intentData = '';
          this.resettoOriginalState();
          this.cdref.detach();
          await this.repopulateDataFromFile(res.body);
          (<HTMLInputElement>document.getElementById('fileuploader')).value = "";

        }
        else {
          this.loginService.startSpinner(false);
          this._notifications.create(res.msg, '', this.errorNotificationType);


          (<HTMLInputElement>document.getElementById('fileuploader')).value = "";
        }
      });
    } else {
      this.loginService.startSpinner(false);
      this._notifications.create('Please choose a file', '', this.errorNotificationType);


    }
  }

Here I am requesting to server through one service which is given below.

reverseFile(value) {
    // const token = localStorage.getItem('token')
    // let headers = new HttpHeaders({
    //   Authorization: 'Bearer ' + token
    // })
    return this.http.post(this.nodeAppUrl + 'reverseFile', value,{ observe: 'response'})
    .pipe(
      tap((res:any) => this.loginService.validateToken(res)),
      map((res:any) => {
        return res.body
      })   
    )
  }

Here the angular is requesting the spinner is starting and after some sec the response also coming from Node.js but as we have the line this.loginService.startSpinner(false); after success message but the spinner is still running.

Here in the response we have more than 2000 records which is in nested array of object format and we are populating the record using this.repopulateDataFromFile(res.body); method. I am attaching below the screen shot of console tool.

enter image description here

Even the status is success I am not able to stop the spinner and also I am not able to expand the record the console which is showing the value was evaluated upon first expanding.......

Can anybody please give any help why it is happening and how to resolve this.

subhra_user
  • 439
  • 5
  • 19

0 Answers0