My code
// Sent Otp URL
FYERS_SENT_OTP_URL=https://api-t2.fyers.in/vagator/v2/send_login_otp_v2
APP_ID_TYPE = 2 // 2 denotes web login
FYERS_ID = YXXXXX2
const axios = require("axios");
require('dotenv').config();
const { FYERS_ID, TOTP_KEY, PIN, CLIENT_ID, SECRET_KEY, REDIRECT_URI, APP_ID_TYPE, FYERS_SENT_OTP_URL, FYERS_VERIFY_OTP_URL, FYERS_VERIFY_PIN_URL, FYERS_TOKEN_URL } = process.env;
async sendLoginOtp(fyId, appId) {
try {
const response = await axios.post(FYERS_SENT_OTP_URL, {
fy_id: fyId,
app_id: appId
});
return response.data.request_key;
} catch (error) {
console.error("Error sending login otp with error:", error.message);
throw new Error("Error sending login otp");
}
}
async generateToken() {
try {
// Send Otp request to fyers API
let requestKey = sendLoginOtp(FYERS_ID, APP_ID_TYPE);
console.log("Request key",requestKey);
} catch (error) {
console.error("Error in generating token", error.message);
throw new Error("Error generating token");
}
}
generateToken();
I got this error:
Error sending login otp with error: Request failed with status code 500