added the endpoint

This commit is contained in:
Ebube
2023-04-10 12:01:59 +01:00
parent f652304468
commit cfa177eaa9
4 changed files with 101 additions and 27 deletions
+2
View File
@@ -7,3 +7,5 @@ REACT_APP_APIGATE='http://float-gat.dev.chiefsoft.net'
REACT_APP_APPLE_LINK='https://apps.apple.com/us/app/float-mobility/id1465369130'
REACT_APP_GOOGLE_PLAY_LINK='https://apps.apple.com/us/app/float-mobility/id1465369130'
REACT_APP_SITE_ENDPOINT='https://float-gat.dev.chiefsoft.net/en/floatweb/api/v1/'
-8
View File
@@ -20,14 +20,6 @@ import GetStarted from './pages/GetStarted';
import FindEv from "./pages/FindEv";
import FindMobility from "./pages/FindMobility";
// import {
// BrowserRouter as Router,
// Routes,
// Route
// } from "react-router-dom";
import { Routes, Route } from "react-router-dom";
+36 -19
View File
@@ -1,26 +1,48 @@
import React, {Component} from 'react';
import SiteService from './assests/utils/SiteService';
class Faqs extends React.Component {
class Faqs extends Component {
constructor({data, loading, error}){
super({data, loading, error})
this.state = {
data: null,
loading: true,
error: null
}
}
async componentDidMount() {
const apiCall = new SiteService
try {
const data = await apiCall.faqData();
this.setState = {
data: data,
loading: false
}
} catch (error) {
this.setState = {
error: error,
loading: false
}
}
}
render() {
const {data, loading, error} = this.state
console.log(data)
console.log(error)
return(
<div>
{/* PRELOADER SPINNER
============================================= */}
{/* PRELOADER SPINNER */}
<div id="loader-wrapper">
<div id="loading">
<span className="cssload-loader"><span className="cssload-loader-inner" /></span>
</div>
</div>
{/* PAGE CONTENT
============================================= */}
{/* PAGE CONTENT */}
<div id="page" className="page">
{/* HEADER
============================================= */}
{/* FAQs-2
============================================= */}
{/* HEADER */}
{/* FAQs-2 */}
<section id="faqs-2" className="bg_whitesmoke hero-offset-nav pb-100 faqs-section division">
<div className="container">
{/* SECTION TITLE */}
@@ -182,8 +204,7 @@ class Faqs extends React.Component {
{/* GEOMETRIC OVERLAY */}
<div className="bg_fixed geometric_overlay" />
</section> {/* END FAQs-2 */}
{/* DOWNLOAD-2
============================================= */}
{/* DOWNLOAD-2 */}
<section id="download-2" className="bg_whitesmoke pb-20 download-section division">
<div className="container white-color">
<div className="rel purple_gradient bg_shape_01 downloads-2-wrapper">
@@ -219,12 +240,8 @@ class Faqs extends React.Component {
</div> {/* End row */}
</div> {/* End container */}
</section> {/* END DOWNLOAD-2 */}
</div> {/* END PAGE CONTENT */}
</div>
</div>
)
}
}
+63
View File
@@ -0,0 +1,63 @@
import axios from 'axios';
class SiteService {
constructor(){
console.log("Launched!!")
}
// GET REQUEST
// Faq Data
faqData(){
return this.getEndPoint("/faq", null)
}
// POST REQUEST
// Contact Data
contactData(){
return this.postEndPoint("/contact")
}
getEndPoint(uri, req){
const endPoint = process.env.REACT_APP_SITE_ENDPOINT + uri;
return axios.get(endPoint)
.then((res) => {
console.log('==> GET REQUEST <==')
console.log(res)
return res
}).catch((err) => {
if (err.response) {
//response status is an error code
console.log(err.response.status);
} else if (err.request) {
//response not received though the request was sent
console.log(err.request);
} else {
//an error occurred when setting up the request
console.log(err.message);
}
})
}
postEndPoint(uri, req){
const endPoint = process.env.REACT_APP_SITE_ENDPOINT + uri;
return axios.get(endPoint, req)
.then((res) => {
console.log(res)
console.log('==> POST REQUEST <==')
return res
}).catch((err) => {
if (err.response) {
//response status is an error code
console.log(err.response.status);
} else if (err.request) {
//response not received though the request was sent
console.log(err.request);
} else {
//an error occurred when setting up the request
console.log(err.message);
}
})
}
}
export default SiteService