@lexa324saa

GET запрос в Postman отдаёт статус 200, а через локальный сервер 304, как исправить?

Есть 2 файла TS
categories-page.component.ts
import {Component, OnInit} from '@angular/core';
import {CategoriesService} from "../shared/servicis/categories.service";
import {Category} from "../shared/interfaces";

@Component({
  selector: 'app-categories-page',
  templateUrl: './categories-page.component.html',
  styleUrls: ['./categories-page.component.css']
})
export class CategoriesPageComponent implements OnInit {
  loading = false
  categor: Category[] = []

  constructor(private categoriesService: CategoriesService) {
  }

  ngOnInit() {
    this.loading = true
    this.categoriesService.fetch().subscribe(categories => {
      this.loading = false
      this.categor = categories
      console.log('Categories', categories)
    })
  }

}

categories.service.ts
import {Injectable} from '@angular/core'
import {HttpClient} from '@angular/common/http'
import {Category} from '../interfaces'
import {Observable} from 'rxjs'

@Injectable({
  providedIn: 'root'
})
export class CategoriesService {
  constructor(private http: HttpClient) {
  }

  fetch(): Observable<Category[]> {
    return this.http.get<Category[]>('/api/category')
  }
}

При get запросе через Postman отдаёт массив категорий, а через сервер отдаёт пустой массив
  • Вопрос задан
  • 301 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы