feat: usar headers personalizados #3
This commit is contained in:
parent
ddc5f1ae3c
commit
3eafdcb7dd
9 changed files with 18 additions and 51 deletions
|
@ -78,7 +78,7 @@ export interface CustomerResponse {
|
|||
|
||||
export async function getCustomers(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
options: CustomerQuery
|
||||
): Promise<CustomerResponse> {
|
||||
let searchParams = new URLSearchParams();
|
||||
|
@ -88,11 +88,7 @@ export async function getCustomers(
|
|||
}
|
||||
const res = await fetch(
|
||||
`${host}/api/Aperture/Customer?${searchParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
{ headers }
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
|
|
6
dummy.ts
6
dummy.ts
|
@ -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`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
headers,
|
||||
});
|
||||
const json = await res.json();
|
||||
if (!json.isOk) {
|
||||
|
|
7
order.ts
7
order.ts
|
@ -114,15 +114,12 @@ export interface OrderResponse {}
|
|||
|
||||
export async function order(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
order: OrderDto
|
||||
): Promise<OrderResponse> {
|
||||
const res = await fetch(`${host}/api/Aperture/order`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
"content-type": "application/json",
|
||||
},
|
||||
headers,
|
||||
body: JSON.stringify(order),
|
||||
});
|
||||
const json = await res.json();
|
||||
|
|
8
price.ts
8
price.ts
|
@ -24,7 +24,7 @@ export interface PriceResponse {
|
|||
|
||||
export async function getPrices(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
options: PriceQuery
|
||||
): Promise<PriceResponse> {
|
||||
let searchParams = new URLSearchParams();
|
||||
|
@ -37,11 +37,7 @@ export async function getPrices(
|
|||
}
|
||||
const res = await fetch(
|
||||
`${host}/api/Aperture/Price?${searchParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
{ headers }
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
|
|
|
@ -28,7 +28,7 @@ export interface PreciosResponse {
|
|||
|
||||
export async function getPricesByCustomer(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
options: PriceByCustomerQuery
|
||||
): Promise<PreciosResponse> {
|
||||
let searchParams = new URLSearchParams();
|
||||
|
@ -44,11 +44,7 @@ export async function getPricesByCustomer(
|
|||
}
|
||||
const res = await fetch(
|
||||
`${host}/api/Aperture/PriceByCustomer?${searchParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
{ headers }
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
|
|
|
@ -23,7 +23,7 @@ export interface PriceListResponse {
|
|||
|
||||
export async function getPriceLists(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
options: PriceListQuery
|
||||
): Promise<PriceListResponse> {
|
||||
let searchParams = new URLSearchParams();
|
||||
|
@ -33,11 +33,7 @@ export async function getPriceLists(
|
|||
}
|
||||
const res = await fetch(
|
||||
`${host}/api/Aperture/PriceList?${searchParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
{ headers }
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
|
|
|
@ -50,7 +50,7 @@ export interface ProductosResponse {
|
|||
// https://github.com/TangoSoftware/ApiTiendas#art%C3%ADculos
|
||||
export async function getProductos(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
options: ProductosQuery
|
||||
): Promise<ProductosResponse> {
|
||||
let searchParams = new URLSearchParams();
|
||||
|
@ -63,11 +63,7 @@ export async function getProductos(
|
|||
}
|
||||
const res = await fetch(
|
||||
`${host}/api/Aperture/Product?${searchParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
{ headers }
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
|
|
|
@ -23,7 +23,7 @@ export interface PublicationsResponse {
|
|||
// https://github.com/TangoSoftware/ApiTiendas#art%C3%ADculos
|
||||
export async function getPublications(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
options: PublicationsQuery
|
||||
): Promise<PublicationsResponse> {
|
||||
let searchParams = new URLSearchParams();
|
||||
|
@ -39,11 +39,7 @@ export async function getPublications(
|
|||
}
|
||||
const res = await fetch(
|
||||
`${host}/api/Aperture/Publications?${searchParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
{ headers }
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
|
|
8
stock.ts
8
stock.ts
|
@ -23,7 +23,7 @@ export interface StockResponse {
|
|||
// https://github.com/TangoSoftware/ApiTiendas#saldos-de-stock
|
||||
export async function getStocks(
|
||||
host: string,
|
||||
token: string,
|
||||
headers: HeadersInit,
|
||||
options: StockQuery
|
||||
): Promise<StockResponse> {
|
||||
let searchParams = new URLSearchParams();
|
||||
|
@ -36,11 +36,7 @@ export async function getStocks(
|
|||
}
|
||||
const res = await fetch(
|
||||
`${host}/api/Aperture/Stock?${searchParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
{ headers }
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
|
|
Loading…
Reference in a new issue