From efc7cbcba15c55ae022a0a58b68b36bd903e6c5c Mon Sep 17 00:00:00 2001 From: Daniel Martinez Date: Sun, 6 Sep 2020 13:38:53 -0500 Subject: [PATCH] Metodo para agregar puntos en services de usuarios --- src/api/API.jsx | 1 + src/services/userService.jsx | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/api/API.jsx b/src/api/API.jsx index 448aa5d..71ea158 100644 --- a/src/api/API.jsx +++ b/src/api/API.jsx @@ -4,3 +4,4 @@ export const HISTORY = "https://coding-challenge-api.aerolab.co/user/history"; export const AUTH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWRkOWU5OTQ0NGZlNDAwNmRhOTkyNGQiLCJpYXQiOjE1OTE1ODIzNjF9.-f40dyUIGFsBSB_PTeBGdSLI58I21-QBJNi9wkODcKk"; export const REDEEEM = "https://coding-challenge-api.aerolab.co/redeem"; +export const ADD_POINTS = "https://coding-challenge-api.aerolab.co/user/points"; diff --git a/src/services/userService.jsx b/src/services/userService.jsx index 64b81d4..70f3d86 100644 --- a/src/services/userService.jsx +++ b/src/services/userService.jsx @@ -17,3 +17,16 @@ export const getUser = async () => { } }; +export const addPoints = async (coins) => { + try { + const response = await fetch(API.ADD_POINTS, { + method: "POST", + body: { amount: coins }, + requestHeaders, + }); + const json = await response.json(); + return json; + } catch (error) { + return alert(JSON.stringify(error)); + } +};