Help

DiscussCategory: Plugin installationImpossible to load the editor!
Bijou Trouvaille asked 2 weeks ago

Hello,

I’m evaluating the plugin, and I followed the getting started tutorial (https://docs.beefree.io/initializing-bee-plugin/) to set up a primitive demo. But it doesn’t work: the html container reports "Impossible to load the editor!" and suggests reloading the page. Below is my code (with keys removed). The execution gets the access token, which looks correct, and attempts to run window.BeePlugin.create but never gets to the callback of that function.

main();

function startBee(token) {

console.log('starting bee', token)

var config = {

uid: 'u121',

container: 'bee-plugin-container',

onError: e=> {

console.log('BEE error: window.ee', window.ee = e);

},

onWarning: e=> {

console.log('BEE warning: window.ee', window.ee = e);

},

onLoad: e=> {

console.log('BEE load: window.ee', window.ll = e);

},

}

window.BeePlugin.create(token, config, function(instance) {

window.i = instance

console.log('instance created. check window.i. run instance.start(tempate)');

console.log('get sample template here: https://rsrc.getbee.io/api/templates/m-bee')

console.log('t = await fetch(`https://rsrc.getbee.io/api/templates/m-bee`); await t.text()')

})

}

function main() {

console.log('authorizing bee');

var endpoint = "https://auth.getbee.io/apiauth";

var payload = {

client_id: "<<obscured>>", // Enter your client id

client_secret: "<<obscured>>", // Enter your secret key

grant_type: "password" // Do not change

};

const form = new FormData();

Object.keys(payload).map(k=>form.append(k, payload[k]));

fetch(endpoint, {

body: form,

method: 'post',

'accept': 'application/json',

})

.then(r => window.r = r)

.then(r => {

if (r.status > 300) {

throw r

} else return r;

})

.then(r => r.text())

.then(token => {

startBee(token)

})

.catch(async e=>{

window.e = e;

console.log(e);

e.text && console.log(await e.text())

})

}

Your Answer