Ancora sistemazioni con typescript....

This commit is contained in:
paolo
2018-11-15 19:48:37 +01:00
parent f5b73414b1
commit 7c49a97217
30 changed files with 626 additions and 253 deletions

42
src/store/Api/index.ts Normal file
View File

@@ -0,0 +1,42 @@
import Request from './Instance'
import sendRequest from './Inst-Pao'
export * from './ApiTypes'
import axios from 'axios'
export {addAuthHeaders, removeAuthHeaders, API_URL, APP_BASE} from './Instance'
// import {AlgoliaSearch} from './AlgoliaController'
import Paths from '@paths'
// const algoliaApi = new AlgoliaSearch()
export namespace ApiTool {
export async function post(path: string, payload?: any) {
return await Request('post', path, payload)
}
export async function postFormData(path: string, payload?: any) {
return await Request('postFormData', path, payload)
}
export async function get(path: string, payload?: any) {
return await Request('get', path, payload)
}
export async function put(path: string, payload?: any) {
return await Request('put', path, payload)
}
export async function Delete(path: string, payload: any) {
return await Request('delete', path, payload)
}
export async function checkSession({token, refresh_token}) {
return await axios.post(process.env.API_URL + Paths.TOKEN_REFRESH, {
refresh_token
}, {
headers: {
'Authorization': `Bearer ${token}`
}
})
}
export async function SendReq(url: string, lang: string, mytok: string, method: string, mydata: any) {
return await sendRequest(url, lang, mytok, method, mydata)
}
}
export default ApiTool