I'm making a first basic MERN Stack where users can enter their name, age and give one link for their social media as like a log book that they visited the page. After taking the link from the user in schema as follows
const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true,
},
age: {
type: Number,
required: true,
},
socialname: {
type: String,
required: true,
},
social: {
type: String,
required: true,
},
});
Now I'm trying to display the link in react with this code
<div>
<h1>{user.name} was here!</h1>
<h1>Age: {user.age}</h1>
<p>Find me on <a href={user.social} target="_blank">{user.socialname}</a></p>
</div>
);
})}
</div>
Now the issue is rather than opening a link I give in the DB (for ex: twitter.com/updwnheadlights) it is opening the link as (http://localhost:3000/twitter.com/updwnheadlights) how can I solve something like this?
I was trying to make sure that when you click on the social media name, the link given by the user open