J.D
2
import { fetch } from 'wix-fetch';
import wixData from 'wix-data';
export function SpEvents(){
const url = "https://system.spektrix.com/eastbournebandstand/api/v3/events";
return fetch(url, {"method":"get"})
.then((httpsResponse) => {
if(!httpsResponse.ok){
return Promise.reject("Did Not Succeed");
}
return httpsResponse.json();
}).then(obj => {
return wixData.insert("SpektrixDB", obj);
})
.catch(err => {
console.log('err',err);
return err;
})
}
//and call the function whenever you want: SpEvents();