Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

An undefined error occurred while attempting to connect to the server. Status code 0: #140

Open
radobson61 opened this issue Sep 30, 2019 · 0 comments

Comments

@radobson61
Copy link

I get the error message

"An undefined error occurred while attempting to connect to the server. Status code 0:"

This is the line throwing the error.

return q.then(function (query)

I get this in both Chrome and Firefox.

I've double and triple checked that the query path is correct.

I'd appreciate any help.

`VSS.init({
explicitNotifyLoaded: true,
usePlatformStyles: true
});

VSS.require(["TFS/Dashboards/WidgetHelpers", "TFS/WorkItemTracking/RestClient"], function (WidgetHelpers, TFS_Wit_WebApi) {

//https://docs.microsoft.com/en-us/vsts/extend/develop/styles-from-widget-sdk?view=vsts
WidgetHelpers.IncludeWidgetStyles();
WidgetHelpers.IncludeWidgetConfigurationStyles();

VSS.register("DaysSinceLoad", function () {
    var projectId = VSS.getWebContext().project.id;

    var getDaysSince = function (widgetSettings) {
        var client = TFS_Wit_WebApi.getClient();
        var q;
        try {
            q = client.getQuery(projectId, "Shared Queries/DaysSince");
        } catch (err) {
            var $daycount = $('h2.count');
            $daycount.text(error.message);
            return WidgetHelpers.WidgetStatusHelper.Success();
        }
        return q.then(function (query) {
            //var days = function (query) {
            //    var daymseconds = 1000 * 60 * 60 * 24;
            //    var today = new Date();
            //    var lastdate = new Date(query.createdDate);
            //    return Math.ceil((today.getTime() - lastdate.getTime())/daymseconds);
            //}
            var $daycount = $('h2.count');
            $daycount.text(query.createdDate);
            return WidgetHelpers.WidgetStatusHelper.Success();
            }, function (error) {
                    var $daycount = $('h2.count');
                    $daycount.text(error.message);
                    return WidgetHelpers.WidgetStatusHelper.Success();
            //return WidgetHelpers.WidgetStatusHelper.Failure(error.message);
        });
    }


    return {
        load: function (widgetSettings) {
            return getDaysSince(widgetSettings);
        }
    };

});

VSS.notifyLoadSucceeded();

});
`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant