Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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;
}
}
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']}`);
}
}
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;
});
}
}
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)
})
}
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
export function get(url, params = '') {
if (params)
return axios(url);
return axios(url,{params:params})
}
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)
})
}
export const fetchRawImage = url => {
const responseType = FileReader ? 'blob' : 'arraybuffer';
return fetch(url, {
method: 'GET',
responseType,
}).then(res => {
const type = res.headers['content-type'];
if (imageTypes.indexOf(type) < 0) {
return Promise.reject(new Error(`Invalid image type: ${type}`));
}
return { data: res.data, type };
});
};