Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function updateGithubComment(commentID, message) {
/* /repos/:owner/:repo/issues/comments/:id */
const commentAPI = `https://api.github.com/repos/${GITHUB_REPO}/issues/comments/${commentID}`
return axios.patch(commentAPI, {
"body": message,
}, config).then(function(response) {
console.log('patch response', response)
return response
});
}
modalConfirmEdits = feedId => {
const title = this.state.title.trim()
const channel = this.state.channel.trim()
const { csrfToken, guildId, feeds } = this.props
const feed = feeds[guildId][feedId] || {}
if ((title === feed.title && !this.state.channel) || (channel === feed.channel && !title) || (title === feed.title && channel === feed.channel) || (!title && !channel)) return this.modalClose()
this.setState({ saving: true, title, channel })
const toSend = {}
if (channel) toSend.channel = channel
if (title) toSend.title = title
if (Object.keys(toSend).length === 0) return this.modalClose()
axios.patch(`/api/guilds/${guildId}/feeds/${feedId}`, toSend, { headers: { 'CSRF-Token': csrfToken } }).then(() => {
this.modalClose(true)
toast.success(`Changes saved. Yay!`)
}).catch(err => {
console.log(err.response || err)
const errMessage = err.response && err.response.data && err.response.data.message ? err.response.data.message : err.response && err.response.data ? err.response.data : err.message
this.setState({ saving: false })
toast.error(<p>Failed to save<br><br>{errMessage ? typeof errMessage === 'object' ? JSON.stringify(errMessage, null, 2) : errMessage : 'No details available'}</p>)
})
}
updateUserRole (index, id) {
axios.patch(config.baseURL + '/website-users/' + id, {
role: this.websiteUsers[index].UserRole
})
.then((res) => {
console.log(res.data)
})
.catch((e) => {
console.log(e)
})
},
deleteUser (id) {
saveTags = async () => {
try {
await axios.patch(`${API}/event-tag`, {
id: this.props.id,
tags: this.state.tags
});
this.props.routerHistory.push("/somepath");
} catch (error) {
console.log(error);
}
};
return request(URL, (mappedURL, args) => {
const [body, params, cancelToken] = args;
return axios.patch(mappedURL, body, { params, cancelToken });
});
};
change() {
const newProgramId = this.selectTarget.value
if (newProgramId !== this.currentProgramId) {
this.element.setAttribute('disabled', 'true');
axios
.patch(`/api/internal/library_entries/${this.libraryEntryIdValue}`, {
program_id: newProgramId,
})
.then(() => {
this.currentProgramId = newProgramId
this.element.removeAttribute('disabled');
this.reloadList()
});
}
}
}
editUser(id, payload) {
return axios.patch(`/users/${id}`, payload)
},
saveUser(payload) {
return new Promise(function(resolve, reject) {
axios.patch(DiscordURL + endpoint,data,{headers: {'Authorization': "Bot " + key}})
.then(function(response){
return resolve(response.data);
})
.catch(function(error){
if(!error.response){
error.response = {
data: error,
status: error.code
}
}
var ErrorObject = {
message: error.response.data.message,
status: error.response.status,
display: "Error ["+error.response.status+"] " + error.response.data.message,
raw: error
refreshInfos() {
this.SET_LOADING(true);
this.SET_ITEM_LOADED_SUBPAGE(false);
http.patch(`${config.api}/refresh/${this.item.id}`).then(response => {
location.reload();
}, error => {
alert(error);
this.SET_LOADING(false);
})
}
},
module.exports.patch = url => data => options => axios.patch(url, data, options)