Skip to content

Commit

Permalink
Añadido /api
Browse files Browse the repository at this point in the history
  • Loading branch information
UO264802 committed May 4, 2022
1 parent 65d7acb commit 1ed6ba5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN npm install

#Create an optimized version of the webapp
#ARG API_URI="http://localhost:5000/api"
ARG API_URI="54.242.225.248:5000"
ARG API_URI="54.242.225.248:5000/api"
ENV REACT_APP_API_URI=$API_URI
RUN npm run build

Expand Down
20 changes: 10 additions & 10 deletions webapp/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CartProduct } from '../shared/shareddtypes';


export async function addOrder(cartProducts:Product[], price:number, url:string, user_id:string|undefined){
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint+'/orders/add', {
method: 'POST',
headers: {'Content-Type':'application/json'},
Expand All @@ -15,7 +15,7 @@ export async function addOrder(cartProducts:Product[], price:number, url:string,
}

export async function getOrdersByUser(user_id:string|undefined){
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint + "/orders/" + user_id);
return response.json();

Expand All @@ -24,27 +24,27 @@ export async function getOrdersByUser(user_id:string|undefined){

//Devuelve los productos de la base de datos
export async function getProducts():Promise<Product[]>{
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint+'/products/list');
//The objects returned by the api are directly convertible to Product objects
return response.json()
}

export async function getProductsByCategory(category: string): Promise<Product[]>{
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint + "/products/" + category);
return response.json();
}

//Producto por código
export async function getProductByCode(code: string): Promise<Product[]>{
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint + "/products/find/" + code);
return response.json();
}

export async function createOrder(DataOrder:ShipmentData):Promise<JSON>{
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000';
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/api';
let response = await fetch(apiEndPoint+'/createOrder',{
method: 'POST',
headers: {'Content-Type':'application/json'},
Expand All @@ -60,7 +60,7 @@ export async function createOrder(DataOrder:ShipmentData):Promise<JSON>{

export async function createTransaction(rate:string):Promise<JSON>{
debugger;
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000';
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/api';
let response = await fetch(apiEndPoint+'/createTransaction',{
method: 'POST',
headers: {'Content-Type':'application/json'},
Expand All @@ -76,7 +76,7 @@ export async function createTransaction(rate:string):Promise<JSON>{


export async function getPedidos(): Promise<Pedido[]> {
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint + '/orders/list');
//The objects returned by the api are directly convertible to User objects
console.log(response);
Expand All @@ -85,14 +85,14 @@ export async function getPedidos(): Promise<Pedido[]> {


export async function getPedidosByUser(user_id:string):Promise<Pedido[]>{
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint+'/orders/'+user_id);
//The objects returned by the api are directly convertible to Product objects
return response.json()
}

export async function getPaymentsType():Promise<PaymentType[]>{
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000'
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint+'/payments');
//The objects returned by the api are directly convertible to Product objects
return response.json()
Expand Down

0 comments on commit 1ed6ba5

Please sign in to comment.