javascript

react login api example

  const [isBookingDone, setIsBookingDone] = useState(false); const [isError, setIsError] = useState(false); const [errorMessage, setErrorMessage] = useState(”); const slotBooking = async (slotTiming, bookedDate, userId) => { let config = { url: `http://localhost:3005/api/bookings`, method: ‘POST’, headers: { ‘Content-Type’: ‘application/json’, }, data: { ‘slotTiming’: slotTiming, ‘bookedDate’: bookedDate, ‘userId’: userId }, }; await axios(config).then((res) => { loadBookingData(); setIsBookingDone(true); }).catch((e) …

react login api example Read More »

Copy to clipboard in jquery

 function copyToClipboard(elementId) { var copyTextarea = document.getElementById(elementId); console.log(copyTextarea); copyTextarea.select(); document.execCommand(“copy”); jQuery(“.copy”).html(“Copied”); if (jQuery(‘.tcopy’).length) { jQuery(‘#’ + elementId.slice(1)).html(“Copied”); } jQuery(“#liveToast”).toast(“show”); }

get date and time from timestamp in js

  function getDateTime(MatchTimeStamp){     var date = new Date(MatchTimeStamp); var Hours = date.getHours() >12 ? date.getHours()-12 : date.getHours(); var ampm = date.getHours() >= 12 ? ‘pm’ : ‘am’; var fullDate = `${date.getDate()}–${date.getMonth()+1}–${ date.getFullYear()}`; var fullTime = `${Hours}:${date.getMinutes()} ${ampm}`; return {‘date’: fullDate , ‘time’ : fullTime} }

Get Unique Object Data From two array of objects in Javascript

var olddata= [     { name:“string 1”, value:“this”, other: “that” }, { name:“string 2”, value:“this”, other: “that” } ]; var newdata = [ { name:“string 1”, value:“this”, other: “that” }, { name:“string 5”, value:“this”, other: “that” }, { name:“string 4”, value:“this”, other: “that” } ]; newdata.forEach((items, index)=>{ if( olddata.findIndex(item => item.name === items.name) == –1){ …

Get Unique Object Data From two array of objects in Javascript Read More »

fixed ‘Switch’ is not exported from ‘react-router-dom’

  I also faced the same problem, and I searched the Internet so much, but I didn’t get any answer according to my question. So I uninstalled version 6 of react-router-dom: npm uninstall react-router-dom And installed version 5.2.0 of react-router-dom: npm install react-router-dom@5.2.0 use below import { BrowserRouter as Router, Switch, Route, Link} from “react-router-dom”;export …

fixed ‘Switch’ is not exported from ‘react-router-dom’ Read More »