Skip to content

Commit

Permalink
Eliminado /api
Browse files Browse the repository at this point in the history
  • Loading branch information
moises.garcia.ext committed May 4, 2022
1 parent 0ab452d commit 0c21849
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
2 changes: 1 addition & 1 deletion webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /app
RUN npm install

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

Expand Down
23 changes: 2 additions & 21 deletions webapp/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,6 @@ import {Product, Pedido, PaymentType} from '../shared/shareddtypes';
import {ShipmentData, User} from '../shared/shareddtypes';
import { CartProduct } from '../shared/shareddtypes';

export async function addUser(user:User):Promise<boolean>{
const apiEndPoint= process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint+'/users/add', {
method: 'POST',
headers: {'Content-Type':'application/json'},
body: JSON.stringify({'name':user.name, 'email':user.email})
});
if (response.status===200)
return true;
else
return false;
}

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

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'
Expand Down Expand Up @@ -63,7 +44,7 @@ export async function getProductByCode(code: string): Promise<Product[]>{
}

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

0 comments on commit 0c21849

Please sign in to comment.