You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
924 B
38 lines
924 B
import axios, {AxiosRequestConfig} from "axios";
|
|
|
|
export class ServerApiRequest {
|
|
|
|
private _axiosConfig: AxiosRequestConfig = {};
|
|
|
|
async getSeoMetadata(slug: string): Promise<any> {
|
|
try {
|
|
const response = await axios.get(`${process.env.STRAPI_URL}/pages?slug=${slug}&populate=deep`);
|
|
console.log(response);
|
|
if (response && response.data) {
|
|
return response.data;
|
|
} else {
|
|
throw new Error('no data');
|
|
}
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
}
|
|
|
|
async getMenu(): Promise<any> {
|
|
try {
|
|
const response = await axios.get(`${process.env.STRAPI_URL}/menus/1?nested&populate=deep`);
|
|
|
|
if (response && response.data) {
|
|
return response.data;
|
|
} else {
|
|
throw new Error('no data');
|
|
}
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
}
|
|
}
|
|
|
|
const serverApiRequest = new ServerApiRequest();
|
|
export default serverApiRequest;
|