以Wix插入Google日历

时间:2018-10-31 12:32:02

标签: insert calendar google-calendar-api wixcode

我正在尝试在Wix中构建Google日历。我想通过表单插入事件。 -我无法导入外部js。 要么 -我无法将插入代码发布到googleApi

import {fetch} from 'wix-fetch';

$w.onReady(function name  () { 
var start = "2018-11-01T10:00:00";
var end   = "2018-11-01T12:00:00";
 sendWithService("0","namesurname", "location", start, end, "note") 
})

//sendGrid.js
export function sendWithService(id,adisoyadi, lokasyon, start, end, not) {
const url = "https://api.sendgrid.com/api/mail.send.json";

const headers = {
"apiKey": apiKey,
"clientId": id,
"scope": 'https://www.googleapis.com/auth/calendar',
"discoveryDocs": ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest']
};


 const data = 'id :' +id "+ ',Description:' + adisoyadi + ', Location:'+lokasyon+' ,Start: ' + start +',End: ' + end+'}';
   //DateTime: "2015-05-28T09:00:00-07:00",
    const request = {
"method": "post", 
"headers": headers, 
"body": data
   };


   return fetch(url, request)
        .then(response => response.json());
      } 

1 个答案:

答案 0 :(得分:0)

Hay Gorkem,

您的代码是在浏览器上运行的页面代码。因此,它受防止跨域调用的浏览器安全策略的约束。

您应该从wix代码后端模块进行访存调用,然后从页面代码导入该模块并进行调用。这将解决跨域问题。