How to use the axios 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 matestack / matestack-ui-core / lib / matestack / ui / vue_js / components / action.js View on Github external
sendRequest: function(){
      const self = this
      axios({
          method: self.componentConfig["method"],
          url: self.componentConfig["action_path"],
          data: self.componentConfig["data"],
          headers: {
            'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
          }
        }
      )
      .then(function(response){
        if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
          matestackEventHub.$emit(self.componentConfig["success"]["emit"], response.data);
        }

        // transition handling
        if (self.componentConfig["success"] != undefined
          && self.componentConfig["success"]["transition"] != undefined
github magma / magma / nms / app / packages / fbcnms-magma-api / client / WebClient.js View on Github external
static async request(
    path: string,
    method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH',
    query: {[string]: mixed},
    // eslint-disable-next-line flowtype/no-weak-types
    body?: any,
  ) {
    const response = await axios({
      baseURL: '/nms/apicontroller/magma/v1/',
      url: path,
      method: (method: string),
      params: query,
      data: body,
      headers: {'content-type': 'application/json'},
    });

    return response.data;
  }
}
github zaiste / facebookgraph / src / index.ts View on Github external
async request(path: string, params, method = 'GET'): Promise {
    try {
      const response = await make({
        headers: { 'User-Agent': 'Facebook Graph Client' },
        method,
        params: Object.assign({ access_token: this.accessToken }, params),
        url: `${this.baseURL}/${path}`
      })

      return response;
    } catch (error) {
      console.log(error.response.status);
      console.log(`  ${error.message}`);
      console.log(`  ${error.response.headers['www-authenticate']}`);
    }
  }
github UNC-Libraries / Carolina-Digital-Repository / static / js / vue-cdr-access / src / components / modalMetadata.vue View on Github external
retrieveContainerMetadata() {
                get(`record/${this.uuid}/metadataView`).then((response) => {
                    this.metadata = response.data;
                    this.showModal = true;
                }).catch(function (error) {
                    console.log(error);
                    this.metadata = '<p>Unable to retrieve metadata for this item</p>';
                    this.showModal = true;
                });
            }
        }
github starlingbank / starling-developer-sdk / src / entities / contact.js View on Github external
getContactAccount (accessToken, contactId) {
    typeValidation(arguments, getContactAccountParameterDefinition)
    const url = `${this.options.apiUrl}/api/v1/contacts/${contactId}/accounts`
    log(`GET ${url}`)
    return axios({
      method: 'GET',
      url,
      headers: defaultHeaders(accessToken)
    })
  }
github rundeck / rundeck / rundeckapp / grails-spa / src / pages / menu / components / userSummary.vue View on Github external
async loadUsersList(offset) {
        this.loading = true
        this.pagination.offset = offset
        axios({
          method: 'get',
          headers: {'x-rundeck-ajax': true},
          url: `${this.rdBase}/user/loadUsersList`,
          params: {
            loggedOnly: `${this.loggedOnly}`,
            includeExec: `${this.includeExec}`,
            offset: this.pagination.offset,
            sessionFilter: this.sessionIdFilter,
            hostNameFilter: this.hostNameFilter,
            loginFilter: this.loginFilter
          },
          withCredentials: true
        }).then((response) => {
          this.pagination.max = response.data.maxRows
          this.pagination.total = response.data.totalRecords
          this.users = response.data.users
github Nealyang / React-Fullstack-Dianping-Demo / frontWeb / fetchApi / get.js View on Github external
export function get(url, params = '') {
    if (params)
        return axios(url);
    return axios(url,{params:params})
}
github starlingbank / starling-developer-sdk / src / entities / account.js View on Github external
getAccountIdentifiers (parameters) {
    parameters = Object.assign({}, this.options, parameters)
    getAccountIdentifiersParameterValidator(parameters)
    const { apiUrl, accessToken, accountUid } = parameters

    const url = `${apiUrl}/api/v2/accounts/${accountUid}/identifiers`
    log(`GET ${url}`)

    return axios({
      method: 'GET',
      url,
      headers: defaultHeaders(accessToken)
    })
  }
github elastic / kibana / common / lib / fetch_image.js View on Github external
export const fetchRawImage = url =&gt; {
  const responseType = FileReader ? 'blob' : 'arraybuffer';

  return fetch(url, {
    method: 'GET',
    responseType,
  }).then(res =&gt; {
    const type = res.headers['content-type'];

    if (imageTypes.indexOf(type) &lt; 0) {
      return Promise.reject(new Error(`Invalid image type: ${type}`));
    }

    return { data: res.data, type };
  });
};