Files
myprojplanet_vite/src/store/Api/Inst-Pao.ts
paoloar77 ce20daed6d Notification with Service Workers now is working!
When a Notification arrives, it save into the IndexDb,
then in Vue.js call a polling to check in the db if there is a different record count.
If is different then call a get to update the notification.
2022-08-07 02:01:20 +02:00

23 lines
767 B
TypeScript
Executable File

import axios, {
AxiosInstance, AxiosPromise, AxiosResponse, AxiosInterceptorManager,
} from 'axios'
import { Api } from '@api'
import * as Types from '@src/store/Api/ApiTypes'
async function sendRequest(url: string, method: string, mydata: any) {
if (process.env.DEBUG) console.log('sendRequest', method, url)
let request
if (method === 'GET') request = Api.get(url, mydata)
else if (method === 'POST') request = Api.post(url, mydata)
else if (method === 'DELETE') request = Api.Delete(url, mydata)
else if (method === 'PUT') request = Api.put(url, mydata)
else if (method === 'PATCH') request = Api.patch(url, mydata)
// @ts-ignore
const req: Promise<Types.AxiosSuccess | Types.AxiosError> = request
return req
}
export default sendRequest