Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
Cómo pasar el parámetro en la URL de reacción js para obtener datos de api

Creé una interfaz de usuario de selector de fecha simple en react js, seleccionando una fecha del menú desplegable, mi API rápida conectada con Redis, ahora cómo almacenar datos en una variable y usar esa variable en URL para OBTENER datos de API

 import React, { Component } from 'react' import axios from 'axios' class PostForm extends Component { constructor(props) { super(props) this.state = { key: '', } console.log(this.state) } changeHandler = e => { this.setState({ [e.target.name]: e.target.value }) } submitHandler = e => { e.preventDefault() console.log(this.state) axios .get('http://127.0.0.1:8000/hvals_hash?key=30/8/21') .then(response => { console.log(response) }) .catch(error => { console.log(error) }) } render() { const { key } = this.state return ( <div> <form onSubmit={this.submitHandler}> <div> <input type="text" name="key" value={key} onChange={this.changeHandler} /> </div> <button type="submit">Submit</button> </form> </div> ) } } export default PostForm

En esa URL quiero pasar como parámetro para obtener datos particulares o datos seleccionados por el usuario. ¿Como hacer eso?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usted define y almacena la key en la tienda de su componente, así que simplemente edite la dirección URL y coloque la key en ella.

 submitHandler = e => { e.preventDefault() axios .get(`http://127.0.0.1:8000/hvals_hash?key=${this.state.key}`) .then(response => { console.log(response) }) .catch(error => { console.log(error) }) }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!