I got some error messages returned:
Access to fetch at ’ [u]https://hq.sinajs.cn/list=gb_fb[/u] ’ from origin ’ https://09ae587e-a224-4913-a5de-302bf9ebc8cb.dev.wix-code.com ’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
Have solved
Should put the code in the Backend Module.
Backend:aModule.jsw
export function GetStockPrice() {
let fullUrl = “https://hq.sinajs.cn/list=hk01308”; return fetch(fullUrl, {method: ‘get’})
.then( (httpResponse) => httpResponse.text())
.then(text => text.split(‘,’)[6])
. catch (err => console.log(err));
}
Page:
import {GetStockPrice} from ‘backend/aModule.jsw’;
export function go_click(event) {
GetStockPrice()
.then(data=>console.log(data))
}