Quick question on last feature in Weather App
I am using an API with the Headers: "x-api-key" way of varifying the key in order to make sure the user can't put in any names that are not cities. The following is my code. Something must be off that I am not aware of because the api wont call. It makes the same 400 error as when i didn't have the key at all: const handleSubmit = async (event) => { event.preventDefault(); if (value) { try { setIsLoading(true); const { data } = await axios( `https://api.api-ninjas.com/v1/city?name=${value}`, { headers: { Authorization: { "x-api-key": "pR/pMV9hptKNyk1e2i5DjQ==s5ppiwzYglSKzYj0", }, }, } ); if (value.toLowerCase() === data.name.toLowerCase()) { const updatedCities = [ ...cities, { city: value, id: Math.random() - Math.random() }, ]; setCities(updatedCities); setValue(""); setIsLoading(false); } } catch (err) { setError(err.message); setIsLoading(false); setTimeout(() => { setError(""); }, 5000); } } }; Link if you need to see more: https://codesandbox.io/p/sandbox/weather-app-qlfvlr?file=%2Fsrc%2Fcomponents%2FNavigation.js%3A16%2C1-49%2C5