How to use odata - 10 common examples

To help you get started, we’ve selected a few odata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pnp / pnpjs / test / sp / features.ts View on Github external
it("site.features.add", async function () {

            // Check if feature is already active.
            const res = await sp.site.features.getById(siteFeatureId)();

            if (res["odata.null"]) {

                // Feature not active already
                return expect(sp.site.features.add(siteFeatureId)).to.be.eventually.fulfilled;
            } else {

                // Feature already active. Call should fail
                return expect(sp.site.features.add(siteFeatureId)).to.be.eventually.rejected;
            }
        });
github forCrowd / WealthFramework / AngularClient / src / main / core / app-http.service.ts View on Github external
handled = true;
                    break;
                }
                case 400: { // Bad request

                    if (body.ModelState) { // WebApi ModelState errors

                        for (let key in body.ModelState) {
                            if (body.ModelState.hasOwnProperty(key)) {
                                body.ModelState[key].forEach(item => {
                                    errorMessage += item + "<br>";
                                });
                            }
                        }

                    } else if (body["odata.error"]) { // OData ModelState errors

                        const errors = body["odata.error"].innererror.message.split("\r\n") as string[];

                        errors.forEach(error =&gt; {

                            error = error.trim();

                            if (error) {
                                errorMessage += error + "<br>";
                            }
                        });

                    } else {
                        errorMessage = body.Message
                            || body.error_description // "Token" end point returns an error response with "error_description"
                            || "";
github forCrowd / WealthFramework / AngularClient / src / main / core / app-http-client / error-interceptor.ts View on Github external
handled = true;
        break;
      }
      case 400: { // Bad request

        if (error.ModelState) { // WebApi ModelState errors

          for (let key in error.ModelState) {
            if (error.ModelState.hasOwnProperty(key)) {
              error.ModelState[key].forEach(item =&gt; {
                errorMessage += item + "<br>";
              });
            }
          }

        } else if (error["odata.error"]) { // OData ModelState errors

          const odataErrors = error["odata.error"].innererror.message.split("\r\n") as string[];

          odataErrors.forEach(odataError =&gt; {

            odataError = odataError.trim();

            if (odataError) {
              errorMessage += odataError + "<br>";
            }
          });

        } else {
          errorMessage = error.Message
            || error.error_description // "Token" end point returns an error response with "error_description"
            || "";
github Breeze / breeze.server.net / Old / AspNetCore / Nuget.builds / Breeze.Client / content / Scripts / adapters / breeze.dataService.odata.js View on Github external
result.statusText = error;
      return result;
    }
    result.message = response.statusText;
    result.statusText = response.statusText;
    result.status = response.statusCode;
    // non std
    if (url) result.url = url;
    result.body = response.body;
    if (response.body) {
      var nextErr;
      try {
        var body = JSON.parse(response.body);
        result.body = body;
        // OData v3 logic
        if (body['odata.error']) {
          body = body['odata.error'];
        }
        var msg = "";
        do {
          nextErr = body.error || body.innererror;
          if (!nextErr) msg = msg + getMessage(body);
          nextErr = nextErr || body.internalexception;
          body = nextErr || body;
        } while (nextErr);
        if (msg.length > 0) {
          result.message = msg;
        }
      } catch (e) {

      }
    }
github Breeze / breeze.js / build / adapters / breeze.dataService.odata.js View on Github external
return result;
    }
    result.message = response.statusText;
    result.statusText = response.statusText;
    result.status = response.statusCode;
    // non std
    if (url) result.url = url;
    result.body = response.body;
    if (response.body) {
      var nextErr;
      try {
        var body = JSON.parse(response.body);
        result.body = body;
        // OData v3 logic
        if (body['odata.error']) {
          body = body['odata.error'];
        }
        var msg = "";
        do {
          nextErr = body.error || body.innererror;
          if (!nextErr) msg = msg + getMessage(body);
          nextErr = nextErr || body.internalexception;
          body = nextErr || body;
        } while (nextErr);
        if (msg.length > 0) {
          result.message = msg;
        }
      } catch (e) {

      }
    }
    proto._catchNoConnectionError(result);
github forCrowd / WealthFramework / ngClient / _system / js / lib / breeze-client / breeze.dataService.odata.js View on Github external
return result;
    }
    result.message = response.statusText;
    result.statusText = response.statusText;
    result.status = response.statusCode;
    // non std
    if (url) result.url = url;
    result.body = response.body;
    if (response.body) {
      var nextErr;
      try {
        var body = JSON.parse(response.body);
        result.body = body;
        // OData v3 logic
        if (body['odata.error']) {
          body = body['odata.error'];
        }
        var msg = "";
        do {
          nextErr = body.error || body.innererror;
          if (!nextErr) msg = msg + getMessage(body);
          nextErr = nextErr || body.internalexception;
          body = nextErr || body;
        } while (nextErr);
        if (msg.length > 0) {
          result.message = msg;
        }
      } catch (e) {

      }
    }
    proto._catchNoConnectionError(result);
github KleeGroup / focus-core / lib / helpers / odata_helper.js View on Github external
function parseOdataResponse(response) {
    if (response === undefined || response === null) {
        throw new Error('Odata error : parsing result');
    }
    // To be comaptible with C# ODataController
    _.extend(response, utilHelper.flatten({
        odata: response.odata
    }));
    delete response.odata;
    if (response["odata.count"] === undefined || response["odata.count"] === null) {
        throw new Error('Odata error : parsing result');
    }
    return {
        totalRecords: response["odata.count"],
        values: response.value
    };
}
github KleeGroup / focus-core / lib / helpers / odata_helper.js View on Github external
function parseOdataResponse(response) {
    if (response === undefined || response === null) {
        throw new Error('Odata error : parsing result');
    }
    // To be comaptible with C# ODataController
    _.extend(response, utilHelper.flatten({
        odata: response.odata
    }));
    delete response.odata;
    if (response["odata.count"] === undefined || response["odata.count"] === null) {
        throw new Error('Odata error : parsing result');
    }
    return {
        totalRecords: response["odata.count"],
        values: response.value
    };
}
github unosquare / tubular / dist / tubular-odata-bundle.js View on Github external
var promise = response.promise.then(function (data) {
                        var result = {
                            Payload: data.value,
                            CurrentPage: 1,
                            TotalPages: 1,
                            TotalRecordCount: 1,
                            FilteredRecordCount: 1
                        };

                        result.TotalRecordCount = parseInt(data['odata.count']);
                        result.FilteredRecordCount = result.TotalRecordCount; // TODO: Calculate filtered items
                        result.TotalPages = parseInt((result.FilteredRecordCount + params.Take - 1) / params.Take);
                        result.CurrentPage = parseInt(1 + ((params.Skip / result.FilteredRecordCount) * result.TotalPages));

                        if (result.CurrentPage > result.TotalPages) {
                            result.CurrentPage = 1;
                            request.data = params;
                            request.data.Skip = 0;

                            request.serverUrl = originalUrl;

                            me.retrieveDataAsync(request).promise.then(function (newData) {
                                result.Payload = newData.value;
                            });
                        }
github Azure / azure-sdk-for-node / lib / services / resourceManagement / lib / resourceManagementClient.js View on Github external
if (modeValue) {
                // how
                var modeInstance = modeValue;
                propertiesInstance.mode = modeInstance;
              }
              
              var parametersValue = propertiesValue['parameters'];
              if (parametersValue) {
                var parametersInstance = parametersValue;
                propertiesInstance.parameters = parametersInstance;
              }
            }
          }
        }
        
        var odatanextLinkValue = responseDoc['odata.nextLink'];
        if (odatanextLinkValue) {
          var odatanextLinkInstance = odatanextLinkValue;
          result.skipToken = odatanextLinkInstance;
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };

odata

o.js is a isomorphic Odata Javascript library to simplify the request of data. The main goal is to build a standalone, lightweight and easy to understand Odata lib.

MIT
Latest version published 8 months ago

Package Health Score

65 / 100
Full package analysis