Budget: 2000 UAH Deadline: 1 day
Hello. I have extensive experience with JavaScript. Ready to collaborate. Contact me
It is necessary to create a script (js method) that will update the number of products via API
- connecting node adminClientAPI (official package)
- updating through mutation GraphQL (or your option)
- updating by delta (+1, -2, etc.)
In fact, the function exists but gives an error that the Input has an incorrect format, other methods in the project work well
Ось весь код який має запрацювати.
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('Failed to mutate inventory:', error);
throw error;
}
}
mutateInventoryQuantity(id, delta)
RESPONSE
Variable $input of type InventoryAdjustQuantitiesInput! was provided invalid value {
value: null,
problems: [ { path: [], explanation: 'Expected value to not be null' } ]
}
Budget: 2000 UAH Deadline: 1 day
Hello. I have extensive experience with JavaScript. Ready to collaborate. Contact me
Budget: 1000 UAH Deadline: 1 day
Good day! I can write/fix such a script!!!!!! Contact me!!!!!!!!!
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' } ]
}
ось така відповідь з сервера
Web Programming 64 proposals 29 July
HTML & CSS 14 proposals 23 July
Web Programming 83 proposals 20 July