I have this code I am using in my Javascript version of the application.
Basically I am passing this object
{
email,
password
}
to a async function.
Then the conveniently rename the email
property to identifier
I wrote the code below:
// Login user
const login = async ({ email: identifier, password }) => {
console.log('login of AuthContext.js')
console.log({ identifier, password })
const res = await fetch(`${NEXT_URL}/api/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
identifier,
password,
}),
})
const data = await res.json()
console.log('data of AuthContext.js', data)
if (res.ok) {
console.log('res.ok of login')
setUser(data.user)
router.push('/account/dashboard')
} else {
console.log('else of login')
console.log('data', data)
setError(data.message)
// setError(null)
}
}
How to convert async ({ email: identifier, password })
into Typescript????