mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-10-05 16:06:51 +08:00
init web ui
This commit is contained in:
39
resources/src/api/githubApi.ts
Normal file
39
resources/src/api/githubApi.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import axios from "axios";
|
||||
import { useSnackbarStore } from "@/stores/snackbarStore";
|
||||
const snackbarStore = useSnackbarStore();
|
||||
// change the access key to your own
|
||||
const ACCESS_KEY = import.meta.env.VITE_GITHUB_CLIENT_ID;
|
||||
|
||||
const instance = axios.create({
|
||||
baseURL: "https://api.github.com",
|
||||
timeout: 20000,
|
||||
headers: { Authorization: "Bearer" + " " + ACCESS_KEY },
|
||||
});
|
||||
|
||||
instance.interceptors.response.use(
|
||||
(response) => {
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
if (error.response) {
|
||||
const status = error.response.status;
|
||||
const data = error.response.data;
|
||||
snackbarStore.showErrorMessage(data.message);
|
||||
} else {
|
||||
snackbarStore.showErrorMessage("Network Error");
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
// https://api.github.com/users/yangjiakai/events/public
|
||||
|
||||
// Get public events for a user
|
||||
export const getPublicEventsApi = (username: string) => {
|
||||
return instance.get("/users/" + username + "/events/public");
|
||||
};
|
||||
|
||||
// Get public events for a network of repositories
|
||||
export const getPublicEventsForNetworkApi = (username: string) => {
|
||||
return instance.get("/networks/" + username + "/events");
|
||||
};
|
Reference in New Issue
Block a user