import axios from "axios"; import dotenv from "dotenv" import Bvn from "../model/bvnModel.js"; export const fetch = async (req, res)=>{ try{ console.log("BVN REQ-----------------------------------------"); console.log(req.body); //{ bvn: '12345678912', '10000000001': '10000000001', verify_mode: 1000 } const userBNV = req.body.bvn; const verifyMode = req.body.verify_mode; console.log("BVN REQ========================================="); const envKey = process.env.VERIFY_ME_PUBLIC_TEST_SECRET; if (verifyMode === 100) // this is live { console.log("BVN REQ LIVE....!! LIVE....!! LIVE....!! LIVE....!! LIVE....!! LIVE....!! "); const envKey = process.env.VERIFY_ME_PUBLIC_LIVE_SECRET; } // 'Authorization': 'Bearer ' + `${process.env.VERIFY_ME_PUBLIC_TEST_SECRET}`, let config = { headers: { 'Authorization': 'Bearer ' + `${envKey}`, 'Content-Type': 'application/json' } }; // const bodyParameters = { // "firstname":"John", // "lastname":"Doe", // "dob":"04-04-1944" // }; const bodyParameters = { "firstname":req.body.firstname, "lastname":req.body.lastname, "dob":req.body.dob }; //22349419550 real live userBNV //10000000001 test // `${process.env.VERIFY_ME_ENDPOINT}/10000000001`, axios.post( `${process.env.VERIFY_ME_ENDPOINT}/${userBNV}`, bodyParameters , config ) .then( async ( response ) => { console.log('BVN CHECK BVN --> ',response.data); //console.log("==============================================="); const bvnData = new Bvn(response.data.data); const saveBvn = await bvnData.save(); console.log("==============================================="); console.log(saveBvn._id); console.log("==============================================="); if ( response.data.status === "success"){ } return res.json({res : response.data}); //console.log( response ) } ) .catch() }catch(error){ res.status(500).json({error: "Internal Server error"}); } }