Client Side
window.hamdast.getSessionToken().then((sessionToken) => {
// Do something with the sessionToken
});
نمونه کد:
// ...
async function login(){
try{
const sessionToken = await window.hamdast.getSessionToken();
await axios.post('https://example.com/login', { session_token: sessionToken });
// Do something after login
} catch(error){
console.error('user rejected the request', error);
}
}
// ...
Server Side
const express = require('express');
const app = express();
const axios = require('axios');
app.post('/login', async (req, res) => {
const { session_token } = req.body;
axios.post("https://hamdast.paziresh24.com/api/v1/auth", { session_token }, {
headers: {
x-api-key: "YOUR_API_KEY"
}
})
.then((response) => {
// Do something with the response
});
});
// ...