type Shopify = {
token: string;
store_name: string;
};
/**
* Retrieves the location of a discount code
* Retrieves the location of a discount code. The discount code's location is returned in the location header, not in the DiscountCode object itself. Depending on your HTTP client, the location of the discount code might follow the location header automatically.
*/
export async function main(auth: Shopify, api_version: string = "2023-10") {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/discount_codes/lookup.json`
);
const response = await fetch(url, {
method: "GET",
headers: {
"X-Shopify-Access-Token": auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 396 days ago
type Shopify = {
token: string;
store_name: string;
};
/**
* Retrieves the location of a discount code
* Retrieves the location of a discount code. The discount code's location is returned in the location header, not in the DiscountCode object itself. Depending on your HTTP client, the location of the discount code might follow the location header automatically.
*/
export async function main(auth: Shopify, api_version: string = "2023-10") {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/discount_codes/lookup.json`
);
const response = await fetch(url, {
method: "GET",
headers: {
"X-Shopify-Access-Token": auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 942 days ago