1
resposta

Não consigo acessar a API do backend = {"message":"route /user/flavio/photos does not exists!"}

import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Photo } from './photo';

const API = 'http://localhost:3000';

//IRÁ CRIAR NO ESCOPO RAÍZ PARA UTILIZAÇÃO DO INJECTOR
@Injectable({ providedIn: 'root' })
export class PhotoService{

    constructor(private http: HttpClient){}

        listFromUser(userName: string){

            return this.http
                .get<Photo[]>(`${API}/${userName}/photos`);

        }

        listFromUserPaginated(userName: string, page: number) {
            const params = new HttpParams()
                .append('page', page.toString());

            return this.http
                .get<Photo[]>(`${API}/${userName}/photos`, { params });
        }

}
1 resposta

Fala ai Guilherme, tudo bem? Estranho, você está rodando o servidor Node? Conseguiu subir a API sem nenhum problemas?

Espero ter ajudado.