type Shopify = {
token: string;
store_name: string;
};
/**
* Retrieves a list of shipping rates
* Retrieves a list of available shipping rates for the specified checkout. Implementers need to poll this endpoint until rates become available. Each shipping rate contains the checkout's new subtotal price, total tax, and total price in the event that this shipping rate is selected. This can be used to update the UI without performing further API requests. To apply a shipping rate, update the checkout's shipping line with the handle of the selected rate.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
token: string
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/checkouts/${token}/shipping_rates.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.json();
}
Submitted by hugo697 61 days ago
type Shopify = {
token: string;
store_name: string;
};
/**
* Retrieves a list of shipping rates
* Retrieves a list of available shipping rates for the specified checkout. Implementers need to poll this endpoint until rates become available. Each shipping rate contains the checkout's new subtotal price, total tax, and total price in the event that this shipping rate is selected. This can be used to update the UI without performing further API requests. To apply a shipping rate, update the checkout's shipping line with the handle of the selected rate.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
token: string
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/checkouts/${token}/shipping_rates.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.json();
}
Submitted by hugo697 606 days ago