headers personalizados #3 #4

Open
fauno wants to merge 3 commits from issue-3 into antifascista
9 changed files with 18 additions and 51 deletions
Showing only changes of commit 3eafdcb7dd - Show all commits

View file

@ -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);

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`, {
method: "POST",
headers: {
accesstoken: token,
},
headers,
});
const json = await res.json();
if (!json.isOk) {

View file

@ -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",
Review

Se deberia aplicar el content-type siempre si lo requiere el endpoint

Se deberia aplicar el content-type siempre si lo requiere el endpoint
Review

en el sitio le puse que siempre esté, no sé por qué en este endpoint específico se agrega y no en otros

en el sitio le puse que siempre esté, no sé por qué en este endpoint específico se agrega y no en otros
Review

A mi entender es porque si se le pasa cosas por el body, en el resto no

A mi entender es porque si se le pasa cosas por el body, en el resto no
},
headers,
body: JSON.stringify(order),
});
const json = await res.json();

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);