Doodle3D-API/src/api/config.js

22 lines
545 B
JavaScript
Raw Normal View History

2017-11-30 17:23:13 +01:00
import { parseFetch } from '../utils.js';
2015-07-15 15:06:18 +02:00
2016-04-21 15:44:20 +02:00
export default class Config {
2016-04-21 15:52:23 +02:00
constructor(api) {
this.api = api;
}
get(...keys) {
2017-11-30 17:23:13 +01:00
return fetch(`${this.api}config/?${keys.join('=&')}=`, { method: 'GET' }).then(parseFetch);
2016-04-21 15:52:23 +02:00
}
getAll() {
2017-11-30 17:23:13 +01:00
return fetch(`${this.api}config/all`, { method: 'GET' }).then(parseFetch);
2016-04-21 15:52:23 +02:00
}
set(data) {
2018-01-25 17:29:51 +01:00
const body = new URLSearchParams();
for (const key in data) {
body.append(key, data[key]);
}
return fetch(`${this.api}config`, { method: 'POST', body }).then(parseFetch);
2016-04-21 15:52:23 +02:00
}
}