[英]How to send data from one website to another website in React js?
讓,我開發了兩個網站: A和B 。 我在 react A網站上創建了一個鏈接。 我想從反應B網站獲取鏈接。
我怎樣才能做到這一點?
您可以通過 URL 的參數從反應 B 網站獲取鏈接
您是否嘗試使用 REST API 從“網站”(解析 HTML)或服務器獲取數據?
在選項 2 中,您的服務器應返回 header 並帶有:
訪問控制允許來源:* 訪問控制允許標頭:*
執行來自另一個域的請求。
然后您可以使用 fetch 方法從服務器獲取數據,如下所示:
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
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.