Budżet: 2000 UAH Termin: 1 dzień
Witam. Mam duże doświadczenie z JavaScript. Gotowy do współpracy. Proszę się kontaktować
Wymagane jest stworzenie skryptu (metody js), który będzie aktualizować ilość produktów za pomocą API
- podłączenie node adminClientAPI (oficjalny pakiet)
- aktualizacja przez mutation GraphQL (lub inny Twój wariant)
- aktualizacja przez delta (+1, -2 i tak dalej)
W rzeczywistości funkcja istnieje, ale zwraca błąd, że z Input ma jakiś nieprawidłowy format, inne metody w projekcie działają poprawnie
Oto cały kod, który musi zacząć działać.
const client = createAdminApiClient({
storeDomain: process.env.SF_DOMAIN,
apiVersion: process.env.SF_API_VERSION,
accessToken: process.env.SF_ADMIN_ACCESS_TOKEN,
});
const mutateInventoryQuantity = async (inventoryItemId, delta) => {
const mutation = `
mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) {
inventoryAdjustQuantities(input: $input) {
userErrors {
field
message
}
inventoryAdjustmentGroup {
createdAt
reason
referenceDocumentUri
changes {
name
delta
}
}
}
}
}
`;
const input = {
reason: "correction",
changes: [
{
delta,
inventoryItemId,
locationId: process.env.SF_CONST_LOCATION_ID
}
]
};
console.log('DEBUG: payload', JSON.stringify({ input }, null, 2));
try {
return await client.request(mutation, { input });
} catch (error) {
console.error('Nie udało się zmodyfikować stanu magazynowego:', error);
throw error;
}
}
mutateInventoryQuantity(id, delta)
ODPOWIEDŹ
Przekazano zmienną $input typu InventoryAdjustQuantitiesInput! z nieprawidłową wartością {
wartość: null,
problemy: [ { ścieżka: [], wyjaśnienie: 'Oczekiwana wartość nie może być null' } ]
}
Zaloguj się lub zarejestruj się, żeby zobaczyć oryginał
Budżet: 2000 UAH Termin: 1 dzień
Witam. Mam duże doświadczenie z JavaScript. Gotowy do współpracy. Proszę się kontaktować
Budżet: 1000 UAH Termin: 1 dzień
Dzień dobry! Mogę napisać/naprawić taki skrypt!!!!!! Skontaktuj się!!!!!!!!!
const mutateInventoryQuantity = async (inventoryItemId, delta) => {
const mutation = `
mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) {
inventoryAdjustQuantities(input: $input) {
userErrors {
field
message
}
inventoryAdjustmentGroup {
createdAt
reason
referenceDocumentUri
changes {
name
delta
}
}
}
}
`;
const input = {
reason: "correction",
changes: [
{
delta,
inventoryItemId,
locationId: process.env.SF_CONST_LOCATION_ID
}
]
};
console.log('DEBUG: payload', JSON.stringify({ input }, null, 2));
try {
return await client.request(mutation, { input });
} catch (error) {
console.error('Failed to mutate inventory:', error);
throw error;
}
}
RESPONSE
Variable $input of type InventoryAdjustQuantitiesInput! was provided invalid value {
value: null,
problems: [ { path: [], explanation: 'Expected value to not be null' } ]
}
ось така відповідь з сервера
Programowanie stron internetowych 64 oferty 29 lipca
Układ HTML i CSS 14 ofert 23 lipca
Programowanie stron internetowych 83 oferty 20 lipca