Skip to content
This repository was archived by the owner on Jan 17, 2024. It is now read-only.
This repository was 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

@radobson61

Description

@radobson61

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();

});
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions