Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wixData from 'wix-data';
- import wixFetch from 'wix-fetch';
- export async function getoptdata() {
- var flagok = false
- let r_json = await wixFetch.fetch("https://5eaf48843844.ngrok.io/optprice", {"method": "get"})
- .then( (httpResponse) => {
- if (httpResponse.ok) {
- flagok = true
- //console.log(httpResponse.json())
- return httpResponse.json();
- } else {
- return Promise.reject("Fetch did not succeed");
- }
- } )
- .catch(err => console.log(err))
- console.log("Hello")
- console.log(r_json)
- console.log(r_json.length)
- //console.log(JSON.parse(r_json)[0])
- //r_json = JSON.parse(r_json)
- //let toInsert =
- if (flagok){
- //parse_df(r_json)
- for(let i = 0; i<r_json.length; i++) {
- await wixData.insert("opt_data", {
- title: i.toString(),
- call1: r_json[i][0],
- call2: r_json[i][1],
- call3: r_json[i][2],
- put1: r_json[i][3],
- put2: r_json[i][4],
- put3: r_json[i][5]
- })
- }
- //await wixData.insert("hv_data", {call1: r_json})
- //const res = await wixData.query('opt_data').limit(200).find();
- //const data = res.items;
- //console.log(data[0]["call1"])
- }
- }
- export async function gethvdata() {
- var flagok = false
- let r_json = await wixFetch.fetch("https://5eaf48843844.ngrok.io/dfhv", {"method": "get"})
- .then( (httpResponse) => {
- if (httpResponse.ok) {
- flagok = true
- //console.log(httpResponse.json())
- return httpResponse.json();
- } else {
- return Promise.reject("Fetch did not succeed");
- }
- } )
- .catch(err => console.log(err))
- console.log(r_json)
- console.log(r_json.length)
- if (flagok){
- await wixData.insert("hv_data", {"jsondata": r_json})
- //const res = await wixData.query('opt_data').limit(200).find();
- //const data = res.items;
- //console.log(data[0]["call1"])
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement