'Uncaught TypeError: Cannot read property 'lat' of undefined React.JS

I have this code that takes the user's location, but when the user does not accept the permission, it sends the error of the question, how could I assign a value to it if the user left it empty?

const request = {
                method: 'POST',
                headers: {
                    "Content-Type": "application/json",
                    "Accept": "application/json"
                },
                body: JSON.stringify({
                    type: "sso",
                    ...state,
                    card: cifrado,
                    latitud: location.coordinates.lat,
                    longitud: location.coordinates.lng,
                    aceptacion: location.aceptacion
                }),
                latitud: location.coordinates.lat,
                longitud: location.coordinates.lng,
                aceptacion: location.aceptacion
            }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source