Next.js Discord

Discord Forum

Can someone expain this code? i'm a begginer in next.js

Unanswered
Sloth bear posted this in #help-forum
Open in Discord
Avatar
Sloth bearOP
const OnSubmit = useCallback(async (e : React.FormEvent)=>{
e.preventDefault();
const formelement = e.target as HTMLFormElement
const Place = formelement.elements.namedItem("place") as HTMLInputElement

const response = await axios.get(https://weatherapi-com.p.rapidapi.com/forecast.json, {
headers: {
'X-RapidAPI-Key': 'testApiKey',
'X-RapidAPI-Host': 'weatherapi-com.p.rapidapi.com',
},
params: {
q: Place.value || 'cairo',
lang: props.lang,
days: '3'
}})
console.log(response.data)
setData(response.data)
},[])

0 Replies