How to use the superagent/lib/client.post function in superagent

To help you get started, we’ve selected a few superagent 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 TeselaGen / openVectorEditor / app / cerebral / actions / loadFromFile.js View on Github external
export default function loadFromFile({input, state, output}) {
    var seqFileParser = require('bio-parsers/parsers/anyToJSON');

    console.log("did it. :3");

    if(id && sid) 
    {
        request
            .post('rest/parts/sequence')
            .set('X-ICE-Authentication-sessionId', sid)
            .set('Content-Type', 'application/json')
            .send(/* results of seqfileparser? or is that on node server*/)
            .end(function(err, result) {
                if(err) {
                    console.log("unable to load file, something went wrong: " + err)
                }
            }
        );
    } else {
        console.log("something went wrong, unable to upload file");
    }

}
github TeselaGen / openVectorEditor / app / cerebral / actions / saveToServer.js View on Github external
featureList[f].id = sequenceData.features[f].id;
        featureList[f].type = sequenceData.features[f].type;
        featureList[f].name = sequenceData.features[f].name;
        featureList[f].strand = sequenceData.features[f].strand;
        featureList[f].notes = sequenceData.features[f].notes;
        featureList[f].locations = [{}];
        featureList[f].locations[0].genbankStart = sequenceData.features[f].start;
        featureList[f].locations[0].end = sequenceData.features[f].end;
    }

    newSequenceData.features = featureList;

    // remember to do checks for bad id and sid and sequence length

    // parts is always parts, even for plasmids and seeds
    request
        .post('rest/parts/' + id + '/sequence?sid=' + sid)
        .set('X-ICE-Authentication-sessionId', sid)
        .set('Content-Type', 'application/json')
        .send(newSequenceData)
        .end(function(err, result) {
            if(err) {
                console.log("unable to save to registry, something went wrong: " + err)
            }
        }
    );
}
github vidi-insights / vidi-dashboard / client / plugins / auth.js View on Github external
function (msg, done) {
      console.log('auth:login', msg)

      function handle_http (err, response) {
        if (err) done(err)
        else done(null, {token: response.body.token})
      }

      var body = {
        username: msg.username,
        password: msg.password
      }

      Request
        .post('/auth/login')
        .type('form')
        .send(body)
        .end(handle_http)
      })
github vidi-insights / vidi-dashboard / lib / client / services / auth.js View on Github external
function login (msg, done) {
      console.log('auth:login', msg)

      Request
        .post('/auth/login')
        .type('form')
        .send({username: msg.username, password: msg.password})
        .end(function (err, reply) {
          if (err) {
            return done(err)
          }

          var newToken = reply.body.token
          varo.act({role: 'session', cmd: 'update', token:newToken},
            function (err) {
              if (err) {
                return done (err)
              }

              token = newToken
github vidi-insights / vidi-dashboard / client / plugins / auth.js View on Github external
function (msg, done) {
      console.log('auth:logout', msg)

      function handle_http (err, response) {
        done(null)
      }

      var body = {
        token: msg.token
      }

      Request
        .post('/auth/logout')
        .type('form')
        .send(body)
        .end(handle_http)
    })
}
github vidi-insights / vidi-dashboard / lib / client / services / auth.js View on Github external
function (msg, done) {
      console.log('auth:logout', msg)

      Request
        .post('/auth/logout')
        .type('form')
        .send({token: token})
        .end(function (err, reply) {
          console.log(reply.text)

          varo.act({role: 'session', cmd: 'clear'},
            function (err) {
              if (err) {
                return done (err)
              }

              locals.isAuthenticated = false
              return done(null, {isAuthenticated: false})
            })
        })
github vidi-insights / vidi-dashboard / client / plugins / profile.js View on Github external
function (msg, done) {
      console.log('user:load', msg)

      if (!msg.token) {
        return done(null, {})
      }

      function handle_http (err, response) {
        if (err) done(null, {})
        else done(null, response.body)
      }

      Request
        .post('/user')
        .type('form')
        .send({token: msg.token})
        .end(handle_http)
    })
}
github vidi-insights / vidi-dashboard / client / actions / auth.js View on Github external
return (dispatch) => {
    dispatch({type: LOGIN_REQUEST})

    Request
      .post('/auth/login')
      .type('form')
      .send({username: user, password: pass})
      .end((err, resp) => {
        if (err || !resp.body.ok) {
          return dispatch({
            type: LOGIN_RESPONSE,
            niceError: 'Wrong username or password, try again',
            hasError: true,
            isLoggedIn: false
          })
        }

        window.localStorage.setItem('user_id', resp.body.user.id)

        dispatch({
github vidi-insights / vidi-dashboard / client / actions / auth.js View on Github external
return (dispatch) => {
    dispatch({type: LOGOUT_REQUEST})

    Request
      .post('/auth/logout')
      .type('form')
      .send({})
      .end(() => {
        window.localStorage.clear()

        unsubscribeSocket(userLogoutUri)
        dispatch({type: LOGOUT_RESPONSE, hasError: false})
        dispatch(pushPath('/login'))
      })
  }
}