added in basic api request
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
.next
|
.next
|
||||||
|
package-lock.json
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import https from 'https';
|
||||||
|
|
||||||
|
|
||||||
|
const agent = new https.Agent({
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
})
|
||||||
|
const crmHeaders = {
|
||||||
|
headers:{
|
||||||
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
"OData-MaxVersion": "4.0",
|
||||||
|
"OData-Version": "4.0",
|
||||||
|
"Accept": "application/json",
|
||||||
|
"Prefer": "odata.include-annotations=\"*\"",
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const getBasicSearch = (searchString) => {
|
||||||
|
console.log('got to axios', searchString)
|
||||||
|
|
||||||
|
return axios
|
||||||
|
//.get("https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=contains(title, '" + searchString + "')&$count=true", crmHeaders,{httpsAgent: new https.Agent({rejectUnauthorized:false})})
|
||||||
|
.get("http://dummy.restapiexample.com/api/v1/employees")
|
||||||
|
.then((res)=>res.data)
|
||||||
|
.catch((error)=>{
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"cookies": "^0.8.0",
|
"cookies": "^0.8.0",
|
||||||
"govuk-frontend": "^3.13.0",
|
"govuk-frontend": "^3.13.0",
|
||||||
|
"https": "^1.0.0",
|
||||||
"jsonpath": "^1.1.1",
|
"jsonpath": "^1.1.1",
|
||||||
"jsonpath-plus": "^5.1.0",
|
"jsonpath-plus": "^5.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import useTranslation from "next-translate/useTranslation";
|
|||||||
|
|
||||||
import { setSearch, getSearchObj } from "../store/search/action";
|
import { setSearch, getSearchObj } from "../store/search/action";
|
||||||
|
|
||||||
|
import {getBasicSearch} from "../actions"
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
const { footerLinks, pages } = props;
|
const { footerLinks, pages } = props;
|
||||||
let { t, lang } = useTranslation();
|
let { t, lang } = useTranslation();
|
||||||
@@ -43,11 +45,12 @@ const Home = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getServerSideProps = wrapper.getServerSideProps(
|
export const getServerSideProps = wrapper.getServerSideProps (
|
||||||
(store) =>
|
store => async({ query, req, res }) =>
|
||||||
({ req, res, query }) => {
|
{
|
||||||
console.log(query);
|
console.log('query-',query);
|
||||||
store.dispatch(setSearch(query.q));
|
const searchResults = await getBasicSearch(query.q)
|
||||||
|
store.dispatch(setSearch(query.q));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
// );
|
// );
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
console.log(state);
|
console.log('mapstate',state);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
search: state.search,
|
search: state.search,
|
||||||
|
|||||||
Reference in New Issue
Block a user