Skip to content

Commit

Permalink
IP maquina
Browse files Browse the repository at this point in the history
  • Loading branch information
UO264802 committed May 4, 2022
2 parents e0a648e + 0c21849 commit 2ff38de
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
2 changes: 1 addition & 1 deletion restapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let bd = require('./utils/connectDB')
const metricsMiddleware:RequestHandler = promBundle({includeMethod: true});
app.use(metricsMiddleware);

app.use(cors(options));
app.use(cors());
app.use(bp.json());
app.use(express.json());

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 2ff38de

Please sign in to comment.