How to use the xhr.put 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 janpaul123 / paperprograms / client / editor / EditorMain.js View on Github external
_save = () => {
    const { code, selectedProgramNumber } = this.state;
    xhr.put(
      getApiUrl(this.props.spaceName, `/programs/${selectedProgramNumber}`),
      {
        json: { code },
      },
      error => {
        if (error) console.error(error); // eslint-disable-line no-console
      }
    );
  };
github enokidotsite / panel / panel / plugins / panel.js View on Github external
function onSave (data) {
    assert.equal(typeof data, 'object', 'enoki: data must be type object')
    assert.equal(typeof data.file, 'string', 'enoki: data.file must be type string')
    assert.equal(typeof data.pathPage, 'string', 'enoki: data.pathPage must be type string')
    assert.equal(typeof data.page, 'object', 'enoki: data.file must be type object')

    emitter.emit(state.events.PANEL_LOADING, { loading: true })
    emitter.emit(state.events.RENDER)

    xhr.put({
      uri: '/api/v1/update',
      body: data,
      json: true
    }, function (err, resp, body) {
      emitter.emit(state.events.PANEL_LOADING, { loading: false })
      emitter.emit(state.events.RENDER)
      if (err) alert(err.message)
    })    
  }
github enokidotsite / panel / panel / plugins / panel.js View on Github external
function onPageAdd (data) {
    assert.equal(typeof data, 'object', 'enoki: data must be type object')
    assert.equal(typeof data.pathPage, 'string', 'enoki: data.pathPage must be type string')
    assert.equal(typeof data.title, 'string', 'enoki: data.title must be type string')
    assert.equal(typeof data.view, 'string', 'enoki: data.view must be type string')

    emitter.emit(state.events.PANEL_LOADING, { loading: true })
    emitter.emit(state.events.RENDER)

    xhr.put({
      uri: '/api/v1/add',
      body: data,
      json: true
    }, function (err, resp, body) {
      emitter.emit(state.events.PANEL_LOADING, { loading: false })
      emitter.emit(state.events.RENDER)
      if (err) return alert(err.message)
      emitter.emit(state.events.REPLACESTATE, data.pathPage + '?panel=active')
    })  
  }
github enokidotsite / panel / panel / plugins / panel.js View on Github external
function onRemove (data) {
    assert.equal(typeof data, 'object', 'enoki: data must be type object')
    assert.equal(typeof data.pathPage, 'string', 'enoki: data.pathPage must be type string')

    if (data.confirm) {
      if (!window.confirm(`Are you sure you want to delete ${data.title || data.pathPage}?`)) {
        return
      }
    }

    emitter.emit(state.events.PANEL_LOADING, { loading: true })
    emitter.emit(state.events.RENDER)

    xhr.put({
      uri: '/api/v1/remove',
      body: data,
      json: true
    }, function (err, resp, body) {
      emitter.emit(state.events.PANEL_LOADING, { loading: false })
      emitter.emit(state.events.RENDER)
      if (err) return alert(err.message)
      if (data.redirect !== false) {
        emitter.emit(state.events.REPLACESTATE, path.join(data.pathPage, '../') + '?panel=active')
      }
    })  
  }
github janpaul123 / paperprograms / client / projector / Program.js View on Github external
_updateDebugData = throttle(() => {
    xhr.put(this._program().debugUrl, { json: this.state.debugData }, () => {});
  }, 300);
github soyking / e3w / static / src / components / request.jsx View on Github external
function UsersChangePassword(name, password, callback) {
    let bodyStr = JSON.stringify({ password: password })
    xhr.put("user/" + encodeURIComponent(name) + "/password", withAuth({ body: bodyStr }), handler(callback))
}
github soyking / e3w / static / src / components / request.jsx View on Github external
function KVPut(path, value, callback) {
    let bodyStr = JSON.stringify({ value: value })
    xhr.put("kv" + path, withAuth({ body: bodyStr }), handler(callback))
}
github soyking / e3w / static / src / components / request.jsx View on Github external
function UsersGrantRole(name, role, callback) {
    xhr.put("user/" + encodeURIComponent(name) + "/role/" + encodeURIComponent(role), withAuth(), handler(callback))
}