How to use the axios/index.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 tronscan / tronscan-frontend / src / components / blockchain / Compiler / index.js View on Github external
for (let key in params) {
            if (params[key] === undefined) {
                continue;
            }
            if (key === 'files') {
                params[key].map(v =>
                    (v instanceof File) ? formData.append('files', v) : formData.append('files', v.originFileObj));
            } else {
                formData.append(key, params[key]);
            }
        }

        // ็ผ–่ฏ‘
        //  const { data } = await xhr.post(`${API_URL}/api/solidity/contract/compile`, formData)
         const { data } = await xhr.post(`${CONTRACT_NODE_API}/api/solidity/contract/compile`, formData)
            .catch(e => {
                const errorData = [{
                    type: 'error',
                    content: `Compiled error: ${e.toString()}`
                }];
                error = errorData.concat(CompileStatus);
            });

        // ้”™่ฏฏ
        if (!data){
            this.setState({
                CompileStatus: error,
                compileLoading: false
            });
            return;
        }
github awsmug / torro-forms / src / assets / src / js / Form / Container / Container.js View on Github external
saveElement(elementId, value, valueId = null) {		
		if( this.state.submissionId === null ) {
			console.error( 'Missing submission id for saving value.' );
			return;
		}

		const submissionValuePostUrl = this.getEndpointUrl( '/submission_values' );

		if( valueId === null ) {

			axios.post(submissionValuePostUrl, {
				form_id: this.formId,
				submission_id: this.state.submissionId,
				element_id: elementId,
				value: value
			})
				.then(response => {
					this.updateElement( elementId, value, response.data.id  );
				})
				.catch( error => {
					console.log( error );
				});
		} else {
			console.log( 'There was a submission on this field!' );
		}
	}
github syscall7 / oda / web / src / api / auth.js View on Github external
export async function logout () {
  const response = await axios.post(store.state.apiRoot + '/odaapi/auth/logout/')
  return response.data
}
github ShiftNrg / shift-hydra / resources / assets / js / components / sync / functions / pushData.js View on Github external
removeFile(title, callback) {
            if (!this.validateSyncInfo(this.syncInfo)) return;

            const that = this;
            let params = new FormData();
            axios.post(this.removeIPFSLink(that.syncInfo.hash, that.syncInfo.path + '/' + title + '/data/json.js'), params, {
                headers: {
                    'content-type': 'multipart/form-data'
                }
            }).then((result) => {
                that.$store.dispatch('setHash', result.data.response.Hash);
                VueEventListener.fire('toggleLoading');
                if (typeof callback !== 'undefined') callback();
            }).catch((error) => {
                VueEventListener.fire('error', error);
                VueEventListener.fire('toggleLoading');
                if (typeof callback !== 'undefined') callback(error);
            });
        },
        removeIPFSLink(hash, path) {
github syscall7 / oda / web / src / api / oda.js View on Github external
export async function createStructure (name) {
  try {
    const response = await axios.post(`/odaapi/api/cstructs/`, {
      short_name: store.state.shortName,
      revision: store.state.revision,
      is_packed: true,
      name: name

    })
    return response.data
  } catch (e) {
    error({e, message: 'creating a structure definition'})
  }
}
github atulmy / crate / code / web / src / modules / common / api / actions.js View on Github external
return dispatch => {
    return axios.post(routeApi + '/upload', data, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  }
}
github syscall7 / oda / web / src / api / oda.js View on Github external
export async function createDefinedData (addr, typeKind, typeName, varName) {
  try {
    const response = await axios.post('/odaapi/api/definedData/', {
      short_name: store.state.shortName,
      revision: store.state.revision,
      vma: addr,
      type_kind: typeKind,
      type_name: typeName,
      var_name: varName
    })
    return response.data
  } catch (e) {
    error({e, message: e.response.data.detail})
  }
}
github tronscan / tronscan-frontend / src / components / account / IssuedToken.js View on Github external
getMarketInfoToken10 = async() => {
        const { issuedAsset } = this.props;
        const { id } = issuedAsset || {};
        if (!!id) {
            const param = {
                tokenIdOrAddr: id
            };
    
            let { data: { data = {} } } = await xhr.post(`${MARKET_API_URL}/api/token/getTokenInfoByTokenIdOrAddr`, param);
            const { tokenOtherInfo, description, sprice, fprice } = data;
            const tokenOtherInfoObj = !!tokenOtherInfo ? JSON.parse(tokenOtherInfo) : {};
            data.description = window.decodeURIComponent(description);
            data = Object.assign(data, tokenOtherInfoObj, { sprice: `${sprice}`, fprice: `${fprice}` });
            this.setState({
                marketInfoToken10: data,
            });
        }
    }
github atulmy / hire-smart / code / web / src / modules / user / api / actions / mutation.js View on Github external
return dispatch => {
    return axios.post(API_URL, {
      operation: 'userResetPasswordVerifyCode',
      params: data
    })
  }
}
github tronscan / tronscan-frontend / src / components / markets / TokenCreate / SubmitInfo.js View on Github external
createToken = async(infoData, tokenId) => {
        const { data: { msg, data = {} } } = await xhr.post(`${MARKET_API_URL}/api/token/addBasicInfo`, infoData);
        const { id } = data;

        this.setState({
            id,
            msg,
        },() => {
            Lockr.rm('TokenLogo');
            this.props.nextState({
                msg,
                id,
                tokenId,
            });
            this.props.nextStep(2);
        });
    };