Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
axios error when template literal in reactjs

I am trying to figure out error dealing with template literal in reactjs(tsx)

export const Features = () => {
  const [features, setFeatures] = useState([]);
  const [isLoading, setLoading] = useState(false);
  const [keywords, setKeywords] = useState("");

  const fetchData = async () => {
    setLoading(true);
    const result = await axios.get("http://123.123.123.123:8000/api/v1/features/?search=" + keywords);
    const result1 = await axios.get(`http://123.123.123.123:8000/api/v1/features?search=${keywords}`);
    setFeatures(result1.data.results);
    setLoading(false);
  };

  ///
  const handlePageChange = () => {
    fetchData();
  };

it works totally fine when I run with result but the issue is result1 These two look totally same but when I run result1 I got a message below

Access to XMLHttpRequest at 'http://52.195.14.97:8000/api/v1/features?search=' 
from origin 'http://52.195.14.97:3000' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.

xhr.js:210 GET http://23.123.123.123:8000/api/v1/features?search= net::ERR_FAILED 301

Could anybody help me figuring this out? I want to run with result1 for some reason :-(

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It seems like you are missing a / in your second url after the features keyword. I am making this assumption based on your first API url that seems to work.

Try changing this: http://123.123.123.123:8000/api/v1/features?search=${keywords}

To this: http://123.123.123.123:8000/api/v1/features/?search=${keywords}

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda