Skip to content

Commit

Permalink
Improrved: added entry for the gitbook api baseUrl, improved method n…
Browse files Browse the repository at this point in the history
…ame (#23)
  • Loading branch information
amansinghbais committed Jun 14, 2024
1 parent f902dd5 commit b912832
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ VUE_APP_COMPANY_PARTY_ID="COMPANY"
VUE_APP_LOGIN_URL="https://launchpad.hotwax.io/login"
VUE_APP_FACILITIES_LOGIN_URL="https://facilities.hotwax.io/login"
VUE_APP_GITBOOK_API_KEY=""
VUE_APP_SPACE_ID=""
VUE_APP_SPACE_ID=""
VUE_APP_GITBOOK_BASE_URL=""
2 changes: 1 addition & 1 deletion src/components/GitBookSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async function fetchSources() {
const responses = await Promise.allSettled(answer.value.sources.map((source: any) => {
if(source.type === "page") {
return UtilService.getGitboookPage(source.page);
return UtilService.getGitBookPage(source.page);
}
}))
Expand Down
29 changes: 11 additions & 18 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import api, {client} from "@/api"
import { hasError } from "@/utils";
import api, {client} from "@/api";

const fetchDBICCountries = async (payload: any): Promise <any> => {
return api({
Expand Down Expand Up @@ -43,54 +42,48 @@ const fetchShipmentMethodTypes = async (payload: any): Promise <any> => {

const askQuery = async (payload: any): Promise <any> => {
const token = process.env.VUE_APP_GITBOOK_API_KEY;
const baseURL = `https://api.gitbook.com/v1/spaces/${process.env.VUE_APP_SPACE_ID}/search/`

return await client({
url: `ask`,
url: `${process.env.VUE_APP_SPACE_ID}/search/ask`,
method: "post",
baseURL,
baseURL: process.env.VUE_APP_GITBOOK_BASE_URL,
data: {
"query": payload.queryString
},
headers: {
Authorization: 'Bearer ' + token,
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
"Content-Type": "application/json"
}
}) as any;
}

const getGitboookPage = async (pageId: any): Promise <any> => {
const getGitBookPage = async (pageId: any): Promise <any> => {
const token = process.env.VUE_APP_GITBOOK_API_KEY;
const baseURL = `https://api.gitbook.com/v1/spaces/${process.env.VUE_APP_SPACE_ID}/`

return await client({
url: `content/page/${pageId}`,
url: `${process.env.VUE_APP_SPACE_ID}/content/page/${pageId}`,
method: "get",
baseURL,
baseURL: process.env.VUE_APP_GITBOOK_BASE_URL,
headers: {
Authorization: 'Bearer ' + token,
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
"Content-Type": "application/json"
}
}) as any;
}

const searchQuery = async (payload: any): Promise <any> => {
const token = process.env.VUE_APP_GITBOOK_API_KEY;
const baseURL = `https://api.gitbook.com/v1/spaces/`

return await client({
url: `${process.env.VUE_APP_SPACE_ID}/search`,
method: "get",
baseURL,
baseURL: process.env.VUE_APP_GITBOOK_BASE_URL,
params: {
"query": payload.queryString
},
headers: {
Authorization: 'Bearer ' + token,
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
"Content-Type": "application/json"
}
}) as any;
}
Expand All @@ -102,6 +95,6 @@ export const UtilService = {
fetchFacilityGroups,
fetchOperatingCountries,
fetchShipmentMethodTypes,
getGitboookPage,
getGitBookPage,
searchQuery
}

0 comments on commit b912832

Please sign in to comment.