juice-shop

Форк
0
/
address.service.ts 
41 строка · 1.5 Кб
1
/*
2
 * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { environment } from '../../environments/environment'
7
import { Injectable } from '@angular/core'
8
import { HttpClient } from '@angular/common/http'
9
import { catchError, map } from 'rxjs/operators'
10

11
@Injectable({
12
  providedIn: 'root'
13
})
14
export class AddressService {
15
  private readonly hostServer = environment.hostServer
16
  private readonly host = this.hostServer + '/api/Addresss'
17

18
  constructor (private readonly http: HttpClient) { }
19

20
  get () {
21
    return this.http.get(this.host).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
22
  }
23

24
  getById (id) {
25
    // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
26
    return this.http.get(`${this.host}/${id}`).pipe(map((response: any) => response.data), catchError((err: Error) => { throw err }))
27
  }
28

29
  save (params) {
30
    return this.http.post(this.host + '/', params).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
31
  }
32

33
  put (id, params) {
34
    // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
35
    return this.http.put(`${this.host}/${id}`, params).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
36
  }
37

38
  del (id: number) {
39
    return this.http.delete(`${this.host}/${id}`).pipe(map((response: any) => response.data), catchError((err) => { throw err }))
40
  }
41
}
42

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.