How to use the xhr.get function in xhr

To help you get started, we’ve selected a few xhr 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 Madek / madek-webapp / app / assets / javascripts / react / decorators / BoxState.js View on Github external
var nextUrl = setUrlParams(
      nextProps.currentUrl,
      {list: {page: nextPage}},
      {
        ___sparse: JSON.stringify(
          l.set({}, nextProps.getJsonPath(), {})
        )
      }
    )

    // We compare the request id when sending started
    // with the request id when the answer arrives and
    // only process the answer when its still the same id.
    var localRequestId = requestId

    return xhr.get(
      {
        url: nextUrl,
        json: true
      },
      (err, res, body) => {

        if(requestId != localRequestId) {
          return
        }

        trigger(merged, {
          action: 'page-loaded',
          resources: l.get(body, nextProps.getJsonPath())
        })
      }
    )
github Madek / madek-webapp / app / assets / javascripts / react / decorators / BoxFetchListData.js View on Github external
job.state = 'loading'

    var currentQuery = parseQuery(
      parseUrl(window.location.toString()).query
    )

    var parsedUrl = parseUrl(job.resource.list_meta_data_url, true)
    delete parsedUrl.search

    var url = setUrlParams(
      buildUrl(parsedUrl),
      currentQuery
    )

    xhr.get(
      {
        url: url,
        json: true
      },
      (err, res, json) => {

        if(err || res.statusCode > 400) {
          // job.state = 'initial'
          callback({
            status: 'failure',
            job: job
          })
          return
        }

        // job.resource.list_meta_data = json
github Madek / madek-webapp / app / assets / javascripts / react / decorators / SuperBox.jsx View on Github external
ajaxGet(urlWithParams, callback) {
    xhr.get(
      {
        url: urlWithParams,
        json: true
      },
      (err, res, json) => {
        callback(json)
      }
    )
  }
github soyking / e3w / static / src / components / request.jsx View on Github external
function UsersGet(name, callback) {
    xhr.get("user/" + encodeURIComponent(name), withAuth(), handler(callback))
}
github LLK / scratch-gui / src / lib / media-library.js View on Github external
getMediaLibrary (libraryType, callback) {
        if (!this._libraryData.hasOwnProperty(libraryType)) {
            this._libraryData[libraryType] = null;
        }
        if (this._libraryData[libraryType]) {
            callback(this._libraryData[libraryType]);
        } else {
            xhr.get({
                useXDR: true,
                url: LIBRARY_URL[libraryType]
            }, (err, response, body) => {
                if (!err) {
                    const data = JSON.parse(body);
                    this._libraryData[libraryType] = data;
                    callback(this._libraryData[libraryType]);
                }
            });
        }
    }
github soyking / e3w / static / src / components / request.jsx View on Github external
function UsersAll(callback) {
    xhr.get("users", withAuth(), handler(callback))
}
github Madek / madek-webapp / app / assets / javascripts / react / decorators / BoxResource.js View on Github external
var sharedLoadMetaData = ({success, error}) => {
    var currentQuery = parseQuery(
      parseUrl(window.location.toString()).query
    )

    var parsedUrl = parseUrl(data.resource.list_meta_data_url, true)
    delete parsedUrl.search

    var url = setUrlParams(
      buildUrl(parsedUrl),
      currentQuery
    )

    xhr.get(
      {
        url: url,
        json: true
      },
      (err, res, json) => {
        if(err || res.statusCode > 400) {
          error()
        } else {
          success(json)
        }
      }
    )

  }
github soyking / e3w / static / src / components / request.jsx View on Github external
function KVGet(path, callback) {
    xhr.get("kv" + path, withAuth(), handler(callback))
}
github soyking / e3w / static / src / components / request.jsx View on Github external
function RolesGet(name, callback) {
    xhr.get("role/" + encodeURIComponent(name), withAuth(), handler(callback))
}