When to use and when not to use encodeURIComponent or encodeURI?

In a security standpoint, when should I use encodeURIComponent or encodeURI and when I don’t need to use it?

Do I need to use encodeURI on "https://nominatim.openstreetmap.org/search.php?q=" as shown below?


And do I need to use them on only GET or also on POST method? On another posted question, there were mixed answers.

$.get(
"https://nominatim.openstreetmap.org/search.php?q=" +
  encodeURIComponent(query) +
  "&polygon_geojson=1&format=jsonv2",
function (response) {
  if (response.length > 0) {
    var latlng = new L.LatLng(response[0].lat, response[0].lon);

    marker.setLatLng(latlng);
    map.panTo(latlng);
    acadp_update_latlng(response[0].lat, response[0].lon);
  }
},
"json"
);