add API namespace
This commit is contained in:
@@ -12,7 +12,7 @@ const Cash = (props) => {
|
|||||||
useEffect( () => {
|
useEffect( () => {
|
||||||
const getCashForHomies = async () => {
|
const getCashForHomies = async () => {
|
||||||
try {
|
try {
|
||||||
const cash = await axios.get(`/homies/cash`);
|
const cash = await axios.get(`/api/homies/cash`);
|
||||||
setHomiesCash(cash.data);
|
setHomiesCash(cash.data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Error fetching", e);
|
console.log("Error fetching", e);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const MakeMoneyMove = (props) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getCashForHomies = async () => {
|
const getCashForHomies = async () => {
|
||||||
try {
|
try {
|
||||||
const cash = await axios.get(`/homies/cash`);
|
const cash = await axios.get(`/api/homies/cash`);
|
||||||
setHomiesCash(cash.data);
|
setHomiesCash(cash.data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Error fetching", e);
|
console.log("Error fetching", e);
|
||||||
@@ -72,7 +72,7 @@ const MakeMoneyMove = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitResponse = await axios.post('/money_moves', moneyMoveRequest);
|
const submitResponse = await axios.post('/api/money_moves', moneyMoveRequest);
|
||||||
|
|
||||||
if (submitResponse && submitResponse.status === 200 && submitResponse.data === true) {
|
if (submitResponse && submitResponse.status === 200 && submitResponse.data === true) {
|
||||||
M.toast({html: "Money lounde...moved"});
|
M.toast({html: "Money lounde...moved"});
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const AddChip = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
const submitResponse = await axios.post('/chips', chipRequest);
|
const submitResponse = await axios.post('/api/chips', chipRequest);
|
||||||
|
|
||||||
if (submitResponse && submitResponse.status === 200 && submitResponse.data) {
|
if (submitResponse && submitResponse.status === 200 && submitResponse.data) {
|
||||||
M.toast({ html: "Chipped In" });
|
M.toast({ html: "Chipped In" });
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const ListChips = (props) => {
|
|||||||
const reloadChipsListEffect = () => {
|
const reloadChipsListEffect = () => {
|
||||||
(async() => {
|
(async() => {
|
||||||
try {
|
try {
|
||||||
const chipsResponse = await axios.get(`/chips`);
|
const chipsResponse = await axios.get(`/api/chips`);
|
||||||
|
|
||||||
if (chipsResponse && chipsResponse.status === 200 && Array.isArray(chipsResponse.data)) {
|
if (chipsResponse && chipsResponse.status === 200 && Array.isArray(chipsResponse.data)) {
|
||||||
setChipsList(chipsResponse.data);
|
setChipsList(chipsResponse.data);
|
||||||
@@ -45,7 +45,7 @@ const ListChips = (props) => {
|
|||||||
|
|
||||||
const deleteChip = async (chipId) => {
|
const deleteChip = async (chipId) => {
|
||||||
try {
|
try {
|
||||||
const chipsResponse = await axios.delete(`/chips/${chipId}`);
|
const chipsResponse = await axios.delete(`/api/chips/${chipId}`);
|
||||||
|
|
||||||
if (chipsResponse && chipsResponse.status === 200 && Array.isArray(chipsResponse.data)){
|
if (chipsResponse && chipsResponse.status === 200 && Array.isArray(chipsResponse.data)){
|
||||||
setChipsList(chipsResponse.data);
|
setChipsList(chipsResponse.data);
|
||||||
@@ -66,7 +66,7 @@ const ListChips = (props) => {
|
|||||||
value: editingChipValue
|
value: editingChipValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const chipsResponse = await axios.post(`/chip_values`, newChipValueObject);
|
const chipsResponse = await axios.post(`/api/chip_values`, newChipValueObject);
|
||||||
|
|
||||||
if (chipsResponse && chipsResponse.status === 200){
|
if (chipsResponse && chipsResponse.status === 200){
|
||||||
setChipsList(chipsResponse.data);
|
setChipsList(chipsResponse.data);
|
||||||
@@ -88,7 +88,7 @@ const ListChips = (props) => {
|
|||||||
value: editingChipValue
|
value: editingChipValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const chipsResponse = await axios.put(`/chip_values/${chipValueId}`, updatedChipValue);
|
const chipsResponse = await axios.put(`/api/chip_values/${chipValueId}`, updatedChipValue);
|
||||||
|
|
||||||
if (chipsResponse && chipsResponse.status === 200){
|
if (chipsResponse && chipsResponse.status === 200){
|
||||||
setChipsList(chipsResponse.data);
|
setChipsList(chipsResponse.data);
|
||||||
@@ -102,7 +102,7 @@ const ListChips = (props) => {
|
|||||||
|
|
||||||
const deleteChipValue = async (chipValueId) => {
|
const deleteChipValue = async (chipValueId) => {
|
||||||
try {
|
try {
|
||||||
const chipsResponse = await axios.delete(`/chip_values/${chipValueId}`);
|
const chipsResponse = await axios.delete(`/api/chip_values/${chipValueId}`);
|
||||||
|
|
||||||
if (chipsResponse && chipsResponse.status === 200){
|
if (chipsResponse && chipsResponse.status === 200){
|
||||||
setChipsList(chipsResponse.data);
|
setChipsList(chipsResponse.data);
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
constraints format: :json do
|
constraints format: :json do
|
||||||
resources :money_moves
|
namespace :api do
|
||||||
resources :chips, only: %i[index create destroy]
|
resources :money_moves
|
||||||
resources :chip_values, only: %i[create update destroy]
|
resources :chips, only: %i[index create destroy]
|
||||||
resources :homies do
|
resources :chip_values, only: %i[create update destroy]
|
||||||
collection do
|
resources :homies do
|
||||||
get 'cash'
|
collection do
|
||||||
|
get 'cash'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user