feat: usar headers personalizados #3

This commit is contained in:
f 2022-11-01 14:21:52 -03:00
parent ddc5f1ae3c
commit 3eafdcb7dd
9 changed files with 18 additions and 51 deletions

View file

@ -78,7 +78,7 @@ export interface CustomerResponse {
export async function getCustomers( export async function getCustomers(
host: string, host: string,
token: string, headers: HeadersInit,
options: CustomerQuery options: CustomerQuery
): Promise<CustomerResponse> { ): Promise<CustomerResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
@ -88,11 +88,7 @@ export async function getCustomers(
} }
const res = await fetch( const res = await fetch(
`${host}/api/Aperture/Customer?${searchParams.toString()}`, `${host}/api/Aperture/Customer?${searchParams.toString()}`,
{ { headers }
headers: {
accesstoken: token,
},
}
); );
const json = await res.json(); const json = await res.json();
console.debug(json); console.debug(json);

View file

@ -1,9 +1,7 @@
export async function dummy(host: string, token: string) { export async function dummy(host: string, headers: HeadersInit) {
const res = await fetch(`${host}/api/Aperture/dummy`, { const res = await fetch(`${host}/api/Aperture/dummy`, {
method: "POST", method: "POST",
headers: { headers,
accesstoken: token,
},
}); });
const json = await res.json(); const json = await res.json();
if (!json.isOk) { if (!json.isOk) {

View file

@ -114,15 +114,12 @@ export interface OrderResponse {}
export async function order( export async function order(
host: string, host: string,
token: string, headers: HeadersInit,
order: OrderDto order: OrderDto
): Promise<OrderResponse> { ): Promise<OrderResponse> {
const res = await fetch(`${host}/api/Aperture/order`, { const res = await fetch(`${host}/api/Aperture/order`, {
method: "POST", method: "POST",
headers: { headers,
accesstoken: token,
"content-type": "application/json",
},
body: JSON.stringify(order), body: JSON.stringify(order),
}); });
const json = await res.json(); const json = await res.json();

View file

@ -24,7 +24,7 @@ export interface PriceResponse {
export async function getPrices( export async function getPrices(
host: string, host: string,
token: string, headers: HeadersInit,
options: PriceQuery options: PriceQuery
): Promise<PriceResponse> { ): Promise<PriceResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
@ -37,11 +37,7 @@ export async function getPrices(
} }
const res = await fetch( const res = await fetch(
`${host}/api/Aperture/Price?${searchParams.toString()}`, `${host}/api/Aperture/Price?${searchParams.toString()}`,
{ { headers }
headers: {
accesstoken: token,
},
}
); );
const json = await res.json(); const json = await res.json();
console.debug(json); console.debug(json);

View file

@ -28,7 +28,7 @@ export interface PreciosResponse {
export async function getPricesByCustomer( export async function getPricesByCustomer(
host: string, host: string,
token: string, headers: HeadersInit,
options: PriceByCustomerQuery options: PriceByCustomerQuery
): Promise<PreciosResponse> { ): Promise<PreciosResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
@ -44,11 +44,7 @@ export async function getPricesByCustomer(
} }
const res = await fetch( const res = await fetch(
`${host}/api/Aperture/PriceByCustomer?${searchParams.toString()}`, `${host}/api/Aperture/PriceByCustomer?${searchParams.toString()}`,
{ { headers }
headers: {
accesstoken: token,
},
}
); );
const json = await res.json(); const json = await res.json();
console.debug(json); console.debug(json);

View file

@ -23,7 +23,7 @@ export interface PriceListResponse {
export async function getPriceLists( export async function getPriceLists(
host: string, host: string,
token: string, headers: HeadersInit,
options: PriceListQuery options: PriceListQuery
): Promise<PriceListResponse> { ): Promise<PriceListResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
@ -33,11 +33,7 @@ export async function getPriceLists(
} }
const res = await fetch( const res = await fetch(
`${host}/api/Aperture/PriceList?${searchParams.toString()}`, `${host}/api/Aperture/PriceList?${searchParams.toString()}`,
{ { headers }
headers: {
accesstoken: token,
},
}
); );
const json = await res.json(); const json = await res.json();
console.debug(json); console.debug(json);

View file

@ -50,7 +50,7 @@ export interface ProductosResponse {
// https://github.com/TangoSoftware/ApiTiendas#art%C3%ADculos // https://github.com/TangoSoftware/ApiTiendas#art%C3%ADculos
export async function getProductos( export async function getProductos(
host: string, host: string,
token: string, headers: HeadersInit,
options: ProductosQuery options: ProductosQuery
): Promise<ProductosResponse> { ): Promise<ProductosResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
@ -63,11 +63,7 @@ export async function getProductos(
} }
const res = await fetch( const res = await fetch(
`${host}/api/Aperture/Product?${searchParams.toString()}`, `${host}/api/Aperture/Product?${searchParams.toString()}`,
{ { headers }
headers: {
accesstoken: token,
},
}
); );
const json = await res.json(); const json = await res.json();
console.debug(json); console.debug(json);

View file

@ -23,7 +23,7 @@ export interface PublicationsResponse {
// https://github.com/TangoSoftware/ApiTiendas#art%C3%ADculos // https://github.com/TangoSoftware/ApiTiendas#art%C3%ADculos
export async function getPublications( export async function getPublications(
host: string, host: string,
token: string, headers: HeadersInit,
options: PublicationsQuery options: PublicationsQuery
): Promise<PublicationsResponse> { ): Promise<PublicationsResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
@ -39,11 +39,7 @@ export async function getPublications(
} }
const res = await fetch( const res = await fetch(
`${host}/api/Aperture/Publications?${searchParams.toString()}`, `${host}/api/Aperture/Publications?${searchParams.toString()}`,
{ { headers }
headers: {
accesstoken: token,
},
}
); );
const json = await res.json(); const json = await res.json();
console.debug(json); console.debug(json);

View file

@ -23,7 +23,7 @@ export interface StockResponse {
// https://github.com/TangoSoftware/ApiTiendas#saldos-de-stock // https://github.com/TangoSoftware/ApiTiendas#saldos-de-stock
export async function getStocks( export async function getStocks(
host: string, host: string,
token: string, headers: HeadersInit,
options: StockQuery options: StockQuery
): Promise<StockResponse> { ): Promise<StockResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
@ -36,11 +36,7 @@ export async function getStocks(
} }
const res = await fetch( const res = await fetch(
`${host}/api/Aperture/Stock?${searchParams.toString()}`, `${host}/api/Aperture/Stock?${searchParams.toString()}`,
{ { headers }
headers: {
accesstoken: token,
},
}
); );
const json = await res.json(); const json = await res.json();
console.debug(json); console.debug(json);