async getToken() { if (this.authToken && this.authToken.expires > new Date().getTime()) { return `_dremio${this.authToken.token}`; } const { data } = await axios.post(`${this.config.url}/apiv2/login`, { userName: this.config.user, password: this.config.password }); this.authToken = data; return `_dremio${this.authToken.token}`; }
async post (url, fields) { const axios = require('axios'); const ErrorHandleUtils = require('./error-handle-utils'); try { const response = await axios.post(buildUrl(url), { fields }, buildRequestParams()); return readDataFromResponse(response); } catch (error) { ErrorHandleUtils.handleResponseError(error); } }
async function post(url, body, options) { try { const response = await axios.post(url, body, options); return response.data; } catch (err) { throw getError(err); } }
fd.pipe(concat({ encoding: 'buffer' }, data => { axios.post('https://safe.moe/api/upload', data, { headers: fd.getHeaders() }) .then((response) => { if (response.data.success === false) { console.error('Error uploading to safe.moe: ', response.description) kuro.error('Error saving sticker. Check logs') return this.saveStickerToDB(name, ext, '') } return this.saveStickerToDB(name, ext, response.data.files[0].url) }) .catch((err) => console.log(err)) }))
const addArticle = async post => { const postData = { body: post.body, title: post.title, username: post.username }; const { data } = await axios.post( `${BASE_URL}/topics/${post.topic}/articles`, postData ); return data; }
resolve(parentValue, { firstName, age, companyId }) { return axios.post('http://localhost:3000/users', { firstName, age, companyId }) .then(res => res.data); }
axios.post(triggerBuildUrl, { build_parameters: buildParameters }) .then(response => { callback(null, 'Success'); }) .catch(error => { callback(error, error.stack); })
const pleskCommand = async params => { return await axios.post(`https://${config.plesk_host}:8443/api/v2/cli/plesk/call`, { params }, { headers: { Authorization: `Basic ${Buffer.from(`${config.plesk_user}:${config.plesk_password}`).toString('base64')}` } }); }
async confirmEmail(token) { return ( await axios.post(`${this.serverUrl}/users/verify`, { email_confirmation_token: token, }) ).data; }
async function main() { const restaurants = await axios.get('http://localhost:3000/restaurants') console.log(restaurants.data) const orderRequest = { restaurantId: 1, menuId: 1, address: 'Wall Street 3, 68443' } const order = await axios.post('http://localhost:3000/order', orderRequest) console.log(order.data) }
async resolve(parentValue, { firstName, age }) { const { data } = await axios.post('http://localhost:3000/users', { firstName, age, }); return data; }
const post = (url, body, options) => axios .post(url, body, options) .then((result) => result.data) .catch((error) => { throw getError(error); })
const checkResponse = async function(secret, response) { const res = await axios.post( `${RECAPTCHA_API_URL}/siteverify`, qs.stringify({ secret, response }) ); return res && res.data; }
async function post(url, body, options) { try { const response = await axios.post(url, body, options); return response.data; } catch (err) { throw getError(err); } }
const getContact = email => axios.post( 'https://api.sendgrid.com/v3/marketing/contacts/search', { query: `email = '${email}'` }, options )