const updateVotes = async (id, loc, voteVal) => { const voteupdate = { inc_votes: voteVal }; const { data } = await axios.patch(`${BASE_URL}/${loc}/${id}`, voteupdate); return data; }
resolve(parentValue, args){ return axios.patch(`http://localhost:3000/users/${args.id}`, args) .then(res => res.data) }
makeTodoDone() { axios.patch(global.API + "/todo/" + this.props.todo.id, { isDone: true } ).catch(error => console.log(error)) }
async enableWatchingPrices () { let url = this.mobileBaseUrl + '/preference/watching/price/enable' const nonce = Date.now() const body = { identity: this.email, nonce } const payload = Buffer.from(JSON.stringify(body)).toString('base64') const signature = crypto .createHmac('sha384', this.apiSecret) .update(payload) .digest('hex') const options = { headers: { 'X-BITOPRO-APIKEY': this.apiKey, 'X-BITOPRO-PAYLOAD': payload, 'X-BITOPRO-SIGNATURE': signature, 'X-BITOPRO-API': this.sdk } } let res = await axios.patch(url, body, options) return res.data }
/** * Create the basic endpoints handlers for CRUD operations * @param {A entity Object} entity */ createBasicCRUDEndpoints( { name } ) { var endpoints = {} const resourceURL = `${this.url}/${name}` endpoints.getAll = ({ query={}}, config={} ) => axios.get(resourceURL, Object.assign({ params: { query }, config })) endpoints.getOne = ({ id }, config={}) => axios.get(`${resourceURL}/${id}`, config) endpoints.create = (toCreate, config={}) => axios.post(resourceURL, toCreate, config) endpoints.update = (toUpdate, config={}) => axios.put(`${resourceURL}/${toUpdate.id}`, toUpdate, config) endpoints.patch = ({id}, toPatch, config={}) => axios.patch(`${resourceURL}/${id}`, toPatch, config) endpoints.delete = ({ id }, config={}) => axios.delete(`${resourceURL}/${id}`, config) endpoints.call = ({ name, id }, config={}) => axios.get(`${resourceURL}/${name}?id=${id}`, config) endpoints.post = (name, id, toCreate, config={}) => axios.post(`${resourceURL}/${name}`, toCreate, config) endpoints.save = (toCreate, config={}) => axios.post(`${resourceURL}/save/`, toCreate, config) return endpoints }
function patch(url, data, state) { return axios .patch(url, data, { headers: { authorization: state.accessToken, }, }) .then((result) => result.data) .catch(async (err) => { if (err && err.response && err.response.status === 401) { await getAccessToken(state); return patch(url, data, state); } return Promise.reject(err); }); }
text: 'United States of Smash was awesome, All Might. Plus Ultra!' }; const response = await axios.patch(`/posts/${postId}`, data); expect(response.status).toBe(200); done();
// json server will ignore id if it's passed to patch req, but nvm async resolve(parentValue, { id, ...args }) { const { data } = await axios.patch(`http://localhost:3000/users/${id}`, { ...args, }); return data; }
resolve (parentValue, args) { return axios.patch(`http://localhost:3000/users/${args.id}`, args) .then(res => res.data) }
makeTodoUndone() { axios.patch(global.API + "/todo/" + this.props.todo.id, { isDone: false } ).catch(error => console.log(error)) }
axios .patch(`http://localhost:3000/users/${args.id}`, args) .then(resp => resp.data)
function patch(url, data, state) { return axios .patch(url, data, { headers: { authorization: state.accessToken, }, }) .then((result) => result.data) .catch(async (err) => { if (err && err.response && err.response.status === 401) { await getAccessToken(state); return patch(url, data, state); } return Promise.reject(err); }); }
async disableWatchingPrices () { let url = this.mobileBaseUrl + '/preference/watching/price/disable' const nonce = Date.now() const body = { identity: this.email, nonce } const payload = Buffer.from(JSON.stringify(body)).toString('base64') const signature = crypto .createHmac('sha384', this.apiSecret) .update(payload) .digest('hex') const options = { headers: { 'X-BITOPRO-APIKEY': this.apiKey, 'X-BITOPRO-PAYLOAD': payload, 'X-BITOPRO-SIGNATURE': signature, 'X-BITOPRO-API': this.sdk } } let res = await axios.patch(url, body, options) return res.data }