115 lines
2.6 KiB
JavaScript
115 lines
2.6 KiB
JavaScript
|
import ApiConnect4 from "./ApiConfig";
|
||
|
|
||
|
export const get_regions = async (data) => {
|
||
|
// console.log(data)
|
||
|
try {
|
||
|
// if (!data.id) {
|
||
|
// throw new Error("data.id is empty or undefined");
|
||
|
// }
|
||
|
const result = await ApiConnect4(`regions/`, {
|
||
|
method: "GET",
|
||
|
// data: data,
|
||
|
// headers: {
|
||
|
// Authorization: `Bearer ${data.token}`,
|
||
|
// },
|
||
|
});
|
||
|
return result;
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
console.log(error + "failed get address api");
|
||
|
|
||
|
return error;
|
||
|
}
|
||
|
};
|
||
|
export const get_provinces = async (data) => {
|
||
|
// console.log(data)
|
||
|
try {
|
||
|
// if (!data.id) {
|
||
|
// throw new Error("data.id is empty or undefined");
|
||
|
// }
|
||
|
const result = await ApiConnect4(`provinces/`, {
|
||
|
method: "GET",
|
||
|
// data: data,
|
||
|
// headers: {
|
||
|
// Authorization: `Bearer ${data.token}`,
|
||
|
// },
|
||
|
|
||
|
});
|
||
|
return result;
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
console.log(error + "failed get address api");
|
||
|
|
||
|
return error;
|
||
|
}
|
||
|
};
|
||
|
export const get_manila_cities = async (data) => {
|
||
|
// console.log(data)
|
||
|
try {
|
||
|
// if (!data.id) {
|
||
|
// throw new Error("data.id is empty or undefined");
|
||
|
// }
|
||
|
const result = await ApiConnect4(`regions/${data.id}/cities/`, {
|
||
|
method: "GET",
|
||
|
// data: data,
|
||
|
// headers: {
|
||
|
// Authorization: `Bearer ${data.token}`,
|
||
|
// },
|
||
|
});
|
||
|
return result;
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
console.log(error + "failed get address api");
|
||
|
|
||
|
return error;
|
||
|
}
|
||
|
};
|
||
|
export const get_cities = async (data) => {
|
||
|
// console.log(data)
|
||
|
try {
|
||
|
if (!data.id) {
|
||
|
throw new Error("data.id is empty or undefined");
|
||
|
}
|
||
|
const result = await ApiConnect4(
|
||
|
`provinces/${data.id}/cities-municipalities/`,
|
||
|
{
|
||
|
method: "GET",
|
||
|
// data: data,
|
||
|
// headers: {
|
||
|
// Authorization: `Bearer ${data.token}`,
|
||
|
// },
|
||
|
}
|
||
|
);
|
||
|
return result;
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
console.log(error + "failed get address api");
|
||
|
|
||
|
return error;
|
||
|
}
|
||
|
};
|
||
|
export const get_barangays = async (data) => {
|
||
|
// console.log(data)
|
||
|
try {
|
||
|
if (!data.id) {
|
||
|
throw new Error("data.id is empty or undefined");
|
||
|
}
|
||
|
const result = await ApiConnect4(
|
||
|
`/cities-municipalities/${data.id}/barangays/`,
|
||
|
{
|
||
|
method: "GET",
|
||
|
// data: data,
|
||
|
// headers: {
|
||
|
// Authorization: `Bearer ${data.token}`,
|
||
|
// },
|
||
|
}
|
||
|
);
|
||
|
return result;
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
console.log(error + "failed get address api");
|
||
|
|
||
|
return error;
|
||
|
}
|
||
|
};
|