first commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import User from "../model/userModel.js";
|
||||
|
||||
export const create = async (req,res)=>{
|
||||
try {
|
||||
const userData = new User(req.body);
|
||||
const { email } = userData;
|
||||
|
||||
const userExist = await User.findOne({email});
|
||||
if (userExist) {
|
||||
return res.status(400).json({message: "User already exixt"});
|
||||
}
|
||||
const saveUser = await userData.save();
|
||||
res.status(200).json(saveUser);
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({error: `Internal Server error 002 ${error} ` });
|
||||
}
|
||||
}
|
||||
|
||||
export const fetch = async (req, res)=>{
|
||||
try{
|
||||
|
||||
return res.json("Hello Worlds");
|
||||
}catch(error){
|
||||
res.status(500).json({error: "Internal Server error"});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import axios from "axios";
|
||||
import dotenv from "dotenv"
|
||||
|
||||
|
||||
export const fetch = async (req, res)=>{
|
||||
try{
|
||||
|
||||
let config = {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + `${process.env.VERIFY_ME_PUBLIC_TEST_SECRET}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
|
||||
const bodyParameters = {
|
||||
"firstname":"John",
|
||||
"lastname":"Doe",
|
||||
"dob":"04-04-1944"
|
||||
};
|
||||
|
||||
axios.post(
|
||||
`${process.env.VERIFY_ME_ENDPOINT}/10000000001`,
|
||||
bodyParameters
|
||||
,
|
||||
config
|
||||
)
|
||||
.then( ( response ) => {
|
||||
return res.json({res : response.data});
|
||||
//console.log( response )
|
||||
} )
|
||||
.catch()
|
||||
|
||||
|
||||
|
||||
}catch(error){
|
||||
res.status(500).json({error: "Internal Server error"});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user