Home > Enterprise >  How to send data from one website to another website in React js?
How to send data from one website to another website in React js?

Time:08-09

Let, I have developed two websites: A and B. I have created a link on the react A website. And I want to get the link from the react B website.

How can I do that?

CodePudding user response:

You can get the link from the react B website by parameter from URL

CodePudding user response:

Are your trying get data from "website" (parse HTML) or data from server using REST API?

In option 2, your server should return header with:

Access-Control-Allow-Origin: * Access-Control-Allow-Headers: *

to execute request from another domain.

Then you can use fetch method to get data from server like this:

       fetch( ConfigX.restApi   "/r,get_training" , {
          method: 'POST', 
          body: JSON.stringify(dataPost),            
      })
      .then( res => res.json() )
      .then(json => {
      
           //console.log(JSON.stringify(json) );
       

           this.setState({
              rows: json.rows,
              result: json.result
           });      
         
      });
  • Related