diff --git a/src/api/categories.js b/src/api/categories.js index dc4500f..2fc3e5a 100644 --- a/src/api/categories.js +++ b/src/api/categories.js @@ -1,16 +1,47 @@ import { config } from '../config'; -import { httpClient } from './httpClient'; export const getAllTicketStatus = () => { - const header = new Headers({ 'Content-Type': 'application/json' }); - const options = { - method: 'GET', - headers: header - }; + const options = { + method: 'GET', + headers: header + }; - return httpClient(`${config.baseURL}categories?type=TicketStatus`, options) + return fetch(`${config.baseURL}categories?type=TicketStatus`, options) + .then(res => { + if (res.ok) { + return res.json(); + } else if (res.status === 404) { + throw new Error('Categories not found.'); + } else { + throw new Error('Ops,problem'); + }; + }); +} + + +export const getAllTicketType = () => { + const header = new Headers({ + 'Content-Type': 'application/json' + }); + + const options = { + method: 'GET', + headers: header + }; + + + return fetch(`${config.baseURL}categories?type=TicketType`, options) + .then(res => { + if (res.ok) { + return res.json(); + } else if (res.status === 404) { + throw new Error('Categories not found.'); + } else { + throw new Error('Ops,problem'); + }; + }); } \ No newline at end of file