/
qwaniii
/
js_gallery
Обзор
Документация
Войти
/
qwaniii
/
js_gallery
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
scripts/api.js
46 строк
1 KB
unknown
add edit logic and modificate
25 янв 2023, 21:00
25 янв 2023, 21:00
de75f54
Код
Авторство
О чём код?
class Api { constructor(name) { this.url = "https://sb-cats.herokuapp.com/api/2/"; this.name = name; } getCats() { return fetch(`${this.url}${this.name}/show`); } getCat(id) { return fetch(`${this.url}${this.name}/show/${id}`) } getIds() { return fetch(`${this.url}${this.name}/ids`) } addCat(body) { return fetch(`${this.url}${this.name}/add`, { method: "POST", headers: { "Accept": "application/json", "Content-Type": "application/json" }, body: JSON.stringify(body) }); } updCat(id, body) { return fetch(`${this.url}${this.name}/update/${id}`, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); } delCat(id) { return fetch(`${this.url}${this.name}/delete/${id}`, { method: "DELETE", }); } }