feat(api): add new methods categories

This commit is contained in:
Francesco Esposito 2019-07-31 15:57:44 +02:00
parent a212b05494
commit e7793fe063
1 changed files with 38 additions and 7 deletions

View File

@ -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');
};
});
}