import { HUB } from './hub';
import config from './config';

export function post (apiUrl, data) {
    const payload = JSON.stringify(data);
    const url = config.API_ROOT + apiUrl;

    GM_xmlhttpRequest({
        method: 'POST',
        url: url,
        headers: {
            'Content-Type': 'application/json',
            'X-Fbtrex-Version': config.VERSION,
            'X-Fbtrex-Build': config.BUILD
        },
        data: payload,
        onload: function (response) {
            HUB.event('syncReponse', { url: url, response: response });
        },
        onerror: function (error) {
            HUB.event('syncError', { url: url, data: JSON.parse(payload), error: error});
        }
    });
}

export const postTimeline = post.bind(null, 'timelines');

export const postDOM = post.bind(null, 'dom');

@@ -588,24 +588,137 @@
 n (error) %7B%0A
+            // We are parsing the payload because %60data%60 will be modified by the handers/sync.js::sync function.%0A
             

Add comment to send func