mirror of https://github.com/franjsco/tick3t
feat(api): add new methods categories
This commit is contained in:
parent
a212b05494
commit
e7793fe063
|
@ -1,8 +1,6 @@
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
import { httpClient } from './httpClient';
|
|
||||||
|
|
||||||
export const getAllTicketStatus = () => {
|
export const getAllTicketStatus = () => {
|
||||||
|
|
||||||
const header = new Headers({
|
const header = new Headers({
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
});
|
});
|
||||||
|
@ -12,5 +10,38 @@ export const getAllTicketStatus = () => {
|
||||||
headers: header
|
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');
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue