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

144
Views
React js: cómo mostrar los resultados de búsqueda en una página separada usando la API de WordPress

Creé un cuadro de búsqueda en reaccionar donde los datos se pueden buscar desde la API de publicación de wordpress. Quiero mostrar los resultados de esta búsqueda en una página separada. desde el siguiente código, la página está redirigiendo a una página en blanco

buscar.js

 import axios from 'axios'; import React, { Component } from 'react'; import { Button } from 'react-bootstrap'; import { Redirect } from '@reach/router'; class Search extends Component { constructor(props) { super(props); this.state = { results: [], term: '', }; this.submit = this.submit.bind(this); this.changeTerm = this.changeTerm.bind(this); } changeTerm(event) { this.setState({ term: event.target.value }); } submit(event) { let url = 'https://example.com/wp-json/wp/v2/posts?_embed&search=' + encodeURI(this.state.term) + '&per_page=100'; axios.get(url) .then(response => { let data = { results: response.data, }; this.setState(data); }) .catch(error => console.log(error)); } render() { return ( <div> <form onSubmit={this.submit} action="search/results"> <input onChange={this.changeTerm} /> <Button type="submit" bsStyle="primary">Find</Button> </form> {this.state.results.length > 0 && <Redirect to={{ pathname: '/search/results', state: { results: this.state.results } }} /> } </div> ); } } export default Search;

resultado.js

about 4 years ago · Juan Pablo Isaza
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!