dev@locazia: add get /account
This commit is contained in:
parent
e052f2232f
commit
a08f742237
25
src/App.tsx
25
src/App.tsx
|
|
@ -20,6 +20,30 @@ function App() {
|
|||
body: JSON.stringify({
|
||||
"twa_data": window.Telegram.WebApp.initData
|
||||
}),
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
if (data["auth_v1_token"] === undefined) {
|
||||
window.location.href = "/unauthorized";
|
||||
return;
|
||||
}
|
||||
setApiToken(data["auth_v1_token"]);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with your fetch operation:', error);
|
||||
});
|
||||
|
||||
fetch(`${apiEndpoint}/account`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': apiToken,
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
|
|
@ -35,6 +59,7 @@ function App() {
|
|||
});
|
||||
} else {
|
||||
console.log("Telegram WebApp not found");
|
||||
window.location.href = "/unauthorized";
|
||||
}
|
||||
}, []);
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
const apiEndpoint: string = process.env.REACT_APP_API_ENDPOINT || 'http://192.168.0.170:13807/api/v1';
|
||||
console.log('process.env.REACT_APP_API_ENDPOINT', process.env.REACT_APP_API_ENDPOINT);
|
||||
|
||||
const apiEndpoint: string = 'https://music-gateway.letsw.app/api/v1';
|
||||
|
||||
export {
|
||||
apiEndpoint
|
||||
|
|
|
|||
Loading…
Reference in New Issue