How to use the axios.post function in axios

To help you get started, weโ€™ve selected a few axios 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 oracle-quickstart / oci-cloudnative / src / api / api / user / index.js View on Github external
app.post("/login", async (req, res, next) => {
        try {
            // client uses basic-auth
            const auth = req.get('authorization');
            const [username, password] = Buffer.from(auth.replace(/^\w+\s/, ''), 'base64').toString('utf8').split(':');
            const { data: user } = await axios.post(endpoints.loginUrl, {
                username,
                password,
            });
            helpers.setAuthenticated(req, res, user.id)
                .status(200)
                .send('OK');
        } catch (e) {
            res.status(401).end();
        }
    });
github bkenio / tidal / tests / do.js View on Github external
const spawnServer = size => {
  return axios.post('https://api.digitalocean.com/v2/droplets', {
    size,
    name: 'video-compression-tester',
    region: 'nyc3',
    image: 'ubuntu-18-04-x64',
    ssh_keys: ['26:e4:37:18:61:e9:29:76:20:68:e1:7f:eb:49:07:2e'],
    user_data: cloudInit,
    tags: ['all'],
  });
};
github TobiahRex / nj2jp / server / graphiql / db / mongo / models / sagawa / index.js View on Github external
console.log('\nFAILED: Find Sagawa document by id: ', sagawaId);

        Transaction
        .handleRefund({ sagawaId, transactionId, userId })
        .then(() => {
          console.log('\nSUCCEEDED: Sagawa.uploadOrder >>> Transaction.handleRefund.');
          resolve({ verified: false, sagawaId });
        })
        .catch((error) => {
          console.log('\nFAILED: Sagawa.uploadOrder >>> Transaction.handleRefund: ', error);
          resolve({ verified: false, sagawaId });
        });
      } else {
        console.log('\nSUCCEEDED: Find Sagawa document by id: ', sagawaDoc._id);
        console.log('\nSending upload to Sagawa...\n');
        return axios.post(
          'http://asp4.cj-soft.co.jp/SWebServiceComm/services/CommService/uploadData',
          `
          
          
            
            
              ${xmlOut('<data>')}
                ${xmlOut(GenerateAddressXml(sagawaDoc))}
                ${xmlOut(GenerateItemsXml(sagawaDoc))}
                ${xmlOut('</data>')}
              
            
            
          `,
          {
            headers: {
github egoist / codepan / src / utils / transform.js View on Github external
const res = JSON.parse(window.ocaml.compile(ocamlCode))
      if (res.js_error_msg) return res.js_error_msg
      return wrapInExports(res.js_code)
    } catch (err) {
      console.log(err)
      return `${err.message}${
        err.location ? `\n${JSON.stringify(err.location, null, 2)}` : ''
      }`
    }
  } else if (transformer === 'coffeescript-2') {
    const esCode = window.CoffeeScript.compile(code)
    return window.Babel.transform(esCode, {
      presets: [...defaultPresets, 'react']
    }).code
  } else if (transformer === 'rust') {
    const { data } = await axios.post('https://play.rust-lang.org/evaluate.json', {
      code,
      optimize: '0',
      version: 'beta'
    })
    if (data.error) {
      return data.error.trim()
    }
    return `console.log(${JSON.stringify(data.result.trim())})`
  }
  throw new Error(`Unknow transformer: ${transformer}`)
}
github trendmicro / SecureCodingDojo / insecureinc / TesterApp / index.js View on Github external
app.post('/attack',(req, res) => {
	const attck = req.body.host;
	const codeSalt = req.body.salt;
	const challenge = req.body.radio;

	console.log('Host: '+ attck);
	console.log('Salt ' + codeSalt);
	console.log('Challenge: '+ challenge);

	var hash = crypto.createHash('sha256').update(codeSalt).digest('base64');
	console.log('Hash ' + hash);
	if(challenge == "1") {
		axios.post(
			'http://' + attck + ':8080/user/register?element_parents=account/mail/#value&ajax_form=1&_wrapper_format=drupal_ajax',
			dataCh1 + hash,
			headersCh
		).then(function (response) {
			//console.log('Response:' + response);
		}).catch(function (error) {
		//	console.log(error);
		});

	} else if (challenge == "2"){
		axios.post(
			'http://' + attck + ':8888/ping.php',
			dataCh22 + hash,
			headersCh
		).then(function (response) {
		//	console.log(response);
github BUPT-HJM / vue-blog / client / src / api / tag.js View on Github external
createTag(name) {
        return Axios.post('/api/tags', {name: name});
    },
    getAllTags() {
github YMFE / yapi / client / containers / Project / Interface / InterfaceList / Run / AddColModal.js View on Github external
addCol = async () => {
    const { addColName: name, addColDesc: desc } = this.state;
    const project_id = this.props.match.params.id
    const res = await axios.post('/api/col/add_col', { name, desc, project_id })
    if (!res.data.errcode) {
      message.success('ๆทปๅŠ ้›†ๅˆๆˆๅŠŸ');
      await this.props.fetchInterfaceColList(project_id);
    } else {
      message.error(res.data.errmsg);
    }
  }
github zijianhuang / webapiclientgen / axios / src / clientapi / WebApiAxiosClientAuto.ts View on Github external
postActionResult(): Promise&gt; {
            return Axios.post(this.baseUri + 'api/SuperDemo/ActionResult', null, { responseType: 'text' }).then(d =&gt; d.data as AxiosResponse);
        }
github YMFE / yapi / client / reducer / modules / project.js View on Github external
export function changeMemberEmailNotice(param) {
  return {
    type: CHANGE_MEMBER_EMAIL_NOTICE,
    payload: axios.post('/api/project/change_member_email_notice', param)
  };
}
github jiemoon / Jblog / resources / assets / admin / api / api.js View on Github external
export const addArticle = params => { return axios.post(`${base}/articles`, params); };