set PAT_1 from backend response, small cleanup

This commit is contained in:
martin-mfg
2025-10-13 13:28:37 +02:00
parent a246be883e
commit adbbce395a
3 changed files with 5 additions and 24 deletions
-1
View File
@@ -31,7 +31,6 @@ const authenticate = async (code, privateAccess, userKey) => {
const getUserMetadata = async (userKey) => {
try {
const fullUrl = `https://${HOST}/api/user-access?user_key=${userKey}`;
// if this returns a 404/400, will the _logout() in AppTrends.js be triggered successfully?
const result = await axios.get(fullUrl);
return result.data;
} catch (error) {
@@ -53,6 +53,7 @@ function WrappedRedirectScreen() {
function App() {
const userId = useSelector((state) => state.user.userId);
const userKey = useSelector((state) => state.user.userKey);
const userToken = useSelector((state) => state.user.token);
const isAuthenticated = userId && userId.length > 0;
const dispatch = useDispatch();
@@ -73,6 +74,10 @@ function App() {
getPrivateAccess();
}, [userKey]);
useEffect(() => {
process.env.PAT_1 = userToken;
}, [userToken]);
return (
<div className="h-screen flex flex-col">
<Router basename="/frontend">
-23
View File
@@ -1,4 +1,3 @@
import axios from 'axios';
import { default as router } from '../../backend/.vercel/output/functions/api.func/router.js';
import React, { useEffect, useState } from 'react';
@@ -148,31 +147,9 @@ const HomeScreen = () => {
console.log('mock http error: ', e);
}
};
const ghToken = prompt('input GitHub token:');
process.env['PAT_1'] = ghToken;
await testEndpoint('/api/wakatime?username=ffflabs');
await testEndpoint('/api/wakatime?username=ffflabsASDF');
console.log('PAT_1: ', process.env.PAT_1);
// console.log(router);
/*
const restResult = await axios.get(
'https://api.github.com/search/commits?q=author:martin-mfg',
);
console.log(restResult);
const ghToken = prompt('input GitHub token:');
const graphqlResult = await axios.post(
'https://api.github.com/graphql',
{
query: 'query { viewer { login }}',
},
{
headers: {
Authorization: `Bearer ${ghToken}`,
},
},
);
console.log(graphqlResult);
*/
} catch (e) {
console.error(e);
}