function post(data) {
  request.post(PATH)
  .send(data)
  .end((err, res) => {
    if (err) {
      handleError(res);
    } else {
      toggleVisibility(successInfo, true);
      successInfo.innerHTML = SUCCESS_MSG;
      toggleVisibility(tokenInfo, true);
      tokenName.innerHTML = 'Token name: ' + res.body.name;
      tokenValue.innerHTML = 'Token value: ' + res.body.token;
      toggleVisibility(errorInfo, false);
      toggleVisibility(formGroup, true); // add margin-top
      input.name.value = ''; // reset value
    }
  });
}
/**
 * Send a POST /v1/tokens request with given payload. Display the token on
 * success or error message on failure.
 *
 * @param {Object} data - The request payload. Expecting JSON with a "name"
 *  attribute.
 */
Send a POST /v1/tokens request with given payload. Display the token on
success or error message on failure.

@param {Object} data - The request payload. Expecting JSON with a "name"
attribute.
Send a POST / v1 / tokens request with given payload . Display the token on success or error message on failure . @param { Object } data - The request payload . Expecting JSON with a " name " attribute .
function post(data) {
  request.post(PATH)
  .send(data)
  .end((err, res) => {
    if (err) {
      handleError(res);
    } else {
      toggleVisibility(successInfo, true);
      successInfo.innerHTML = SUCCESS_MSG;
      toggleVisibility(tokenInfo, true);
      tokenName.innerHTML = 'Token name: ' + res.body.name;
      tokenValue.innerHTML = 'Token value: ' + res.body.token;
      toggleVisibility(errorInfo, false);
      toggleVisibility(formGroup, true); 
      input.name.value = ''; 
    }
  });
}
function post ( data ) { request . post ( PATH ) . send ( data ) . end ( ( err , res ) => { if ( err ) { handleError ( res ) ; } else { toggleVisibility ( successInfo , true ) ; successInfo . innerHTML = SUCCESS_MSG ; toggleVisibility ( tokenInfo , true ) ; tokenName . innerHTML = 'Token name: ' + res . body . name ; tokenValue . innerHTML = 'Token value: ' + res . body . token ; toggleVisibility ( errorInfo , false ) ; toggleVisibility ( formGroup , true ) ; input . name . value = '' ; } } ) ; }
Send a POST /v1/tokens request with given payload.
Send a POST / v1 / tokens request with given payload .
// add margin-top // reset value