Widget API
Webfuse is a JavaScript API which helps to work with Spaces. It provides methods to initialize and interact with Webfuse Spaces.
Installation
Add the following snippet to your webpage: Note: Every Webfuse space will have a different widget key.
// Load Webfuse script
(function(s,u,r,f,l,y){
s[f] = s[f] || {
initSpace: function() {
return new Promise((resolve) => {
s[f].q = arguments;
s[f].resolve = resolve;
});
}
};
l = u.createElement(r);
y = u.getElementsByTagName(r)[0];
l.async = 1;
l.src = 'https://sarea.net/surfly.js';
y.parentNode.insertBefore(l,y);
})(window,document,'script','WebFuse');
// Initialize WebFuse space
WebFuse.initSpace(
'your_widget_key', // Widget Key (required)
'your_space_id', // Space ID (required)
{} // Integration Settings (optional)
)
.then(space => {
console.log('Space:', space);
console.log('Space ID:', space.id);
console.log('Space slug:', space.slug);
})
.catch(error => {
console.error('Failed:', error);
});
Parameters
widgetKey
: The widget key for the Surfly space.spaceId
: The ID of the Surfly space.integrationSettings
: An object containing integration settings.
Return Value
The initSpace
method returns a Promise that resolves with a Space object containing:
id
: The space IDslug
: The space slugdata
: The full space data object
Error Handling
If initialization fails, the Promise will be rejected with an error that can be caught using .catch()
.