Home>

I have a project onAngularJs. I will say that I did not write the project from scratch, and I know very littleAngular.

Here I want one simplehttpmake a request to the server. And the matter is that the request does not work at all. Doesn't give any errors. AS IF THESE LINES OF CODE WERE NOT WRITTEN AT ALL.

Before and after the code, I do the logs, everything works. The code was uploaded totry -catchand again there is no error.

Can someone tell me what I'm doing wrong? And which way should I go?

Here is the code.

import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import {ResultsFacade} from '../../../results/results.facade';
import {Company} from '../../../company/model/company.model';
import {HttpClient, HttpErrorResponse, HttpHeaders} from '@angular/common/http';
@Component({
  selector: 'app-people-table',
  templateUrl: './people.table.component.html',
  styleUrls: ['./people.table.component.css']
})
export class PeopleTableComponent implements OnInit, OnDestroy {
  constructor(private modalService: NgbModal, private resultsFacade: ResultsFacade, private httpClient: HttpClient) { }
  ngOnInit() {
  }
  getData(result): void {
    console.log(`${environment.api_url}/company/data-details/${result.id}`);
    try {
      this.httpClient.post(`${environment.api_url}/company/data-details/${result.id}`, {}).pipe(
          map( (response: any)=> {
            console log(response);
          }));
    } catch (e) {
      console.error(e);
    }
    console.log(2222222222);
  }
}

And here is what is displayed in the log. And in ՝network՝ there is nothing in the browser. No request.

Here is the log andnetwork.

if there are no subscribers Observer is not executed

Grundy2022-02-12 21:24:16

@Grundy can you be a little more specific? I generally do Backend, but I had to touch this part of the front.

Raz Galstyan2022-02-12 21:24:16

The code inside new Observable(function subscribe(subscriber) {...}) represents an "Observable execution", a lazy computation that only happens for each Observer that subscribes.

Grundy2022-02-12 21:24:16