In a large bowl, mix the black-eyed pea flour, salt, and chili (if using).
Gradually pour in the warm water, mixing until a thick, smooth batter similar to pancake batter is formed. It should not be too runny.
Add the grated onion and crushed garlic. Mix well.
In a pan or small pot, heat the palm oil (or vegetable oil) over medium heat. The oil should be hot but not smoking (about 185 °C (365 °F)).
Use a spoon to scoop the batter and pour it into the hot oil. The fritters should be small, about 3–4 cm in diameter.
Fry the fritters for 3–4 minutes on each side until they are evenly golden brown and cooked through.
Remove them from the oil and let them drain on a paper towel to remove excess fat.