diff --git a/src/api/API.jsx b/src/api/API.jsx index e515b4c..448aa5d 100644 --- a/src/api/API.jsx +++ b/src/api/API.jsx @@ -1,4 +1,6 @@ export const PRODUCTS = "https://coding-challenge-api.aerolab.co/products"; export const USER = "https://coding-challenge-api.aerolab.co/user/me"; export const HISTORY = "https://coding-challenge-api.aerolab.co/user/history"; -export const AUTH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWRkOWU5OTQ0NGZlNDAwNmRhOTkyNGQiLCJpYXQiOjE1OTE1ODIzNjF9.-f40dyUIGFsBSB_PTeBGdSLI58I21-QBJNi9wkODcKk"; +export const AUTH_TOKEN = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZWRkOWU5OTQ0NGZlNDAwNmRhOTkyNGQiLCJpYXQiOjE1OTE1ODIzNjF9.-f40dyUIGFsBSB_PTeBGdSLI58I21-QBJNi9wkODcKk"; +export const REDEEEM = "https://coding-challenge-api.aerolab.co/redeem"; diff --git a/src/services/productsService.jsx b/src/services/productsService.jsx index 223badb..bfa3ac4 100644 --- a/src/services/productsService.jsx +++ b/src/services/productsService.jsx @@ -16,3 +16,17 @@ export const getProducts = async () => { return alert(JSON.stringify(error)); } }; + +export const redeemProduct = async (id) => { + try { + const response = await fetch(API.REDEEEM, { + method: "POST", + body: { productId: id }, + requestHeaders, + }); + const json = await response.json(); + return json; + } catch (error) { + return alert(JSON.stringify(error)); + } +}; diff --git a/src/services/userService.jsx b/src/services/userService.jsx index eac460e..64b81d4 100644 --- a/src/services/userService.jsx +++ b/src/services/userService.jsx @@ -16,3 +16,4 @@ export const getUser = async () => { return alert(JSON.stringify(error)); } }; +