fix undefined `res` error