Forcing usage of id to getOne
This commit is contained in:
@@ -33,7 +33,7 @@ export const FirmRoutes = () => {
|
|||||||
|
|
||||||
const FirmHome = () => {
|
const FirmHome = () => {
|
||||||
const { currentFirm } = useContext(FirmContext);
|
const { currentFirm } = useContext(FirmContext);
|
||||||
const { data: firm, isError, error, isLoading } = useOne({resource: 'firm', id: `${currentFirm.instance}/${currentFirm.firm}`, errorNotification: false})
|
const { data: firm, isError, error, isLoading } = useOne({resource: 'firm', id: `${currentFirm.instance}/${currentFirm.firm}/`, errorNotification: false})
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <h1>Loading...</h1>
|
return <h1>Loading...</h1>
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ const API_URL = "/api/v1";
|
|||||||
|
|
||||||
export const dataProvider: DataProvider = {
|
export const dataProvider: DataProvider = {
|
||||||
getOne: async ({ resource, id, meta }) => {
|
getOne: async ({ resource, id, meta }) => {
|
||||||
const response = id !== "" ? await fetch(`${API_URL}/${resource}/${id}`) : await fetch(`${API_URL}/${resource}`);
|
if (id === "") {
|
||||||
|
return { data: undefined };
|
||||||
|
}
|
||||||
|
const response = await fetch(`${API_URL}/${resource}/${id}`);
|
||||||
if (response.status < 200 || response.status > 299) {
|
if (response.status < 200 || response.status > 299) {
|
||||||
if (response.status == 405) {
|
if (response.status == 405) {
|
||||||
const error: HttpError = {
|
const error: HttpError = {
|
||||||
|
|||||||
Reference in New Issue
Block a user