Skip to content

Commit

Permalink
Metodo en service de productos para canjear
Browse files Browse the repository at this point in the history
  • Loading branch information
hendaniel committed Sep 6, 2020
1 parent d06f653 commit e295928
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/api/API.jsx
Original file line number Diff line number Diff line change
@@ -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";
14 changes: 14 additions & 0 deletions src/services/productsService.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
};
1 change: 1 addition & 0 deletions src/services/userService.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export const getUser = async () => {
return alert(JSON.stringify(error));
}
};

0 comments on commit e295928

Please sign in to comment.