Search code examples
javascriptsyntax-errorvelo

What am I doing wrong? (Coding Syntax Error)


enter image description here

Why do I get red lines on fieldName and order? I’m following the API reference here:

https://www.wix.com/velo/reference/wix-pricing-plans-backend/orders/listcurrentmemberorders

Here's a sample from the example in the reference:

/* Sample filters object: 
 * {
 *   orderStatuses: ['PAUSED', 'CANCELED']
 * }
 */

/* Sample sorting object: 
 * {
 *   fieldName: ['createdDate'], 
 *   order: ['ASC']
 * }
 */

/* Sample paging object: 
 * {
 *   limit: 3,
 *   skip: 1
 * }
 */

The red line error says: Type 'string[]' is not assignable to type 'string'

I feel like I’m doing what the linked reference says, and have tried various setups from exploring the reference.

(EDIT: And the next thing to look into would be why orders on listedOrders.orders throws the error: Property 'orders' does not exist on type 'Order[]'. )

Is the answer that the API reference is outdated?


Solution

  • I think the comment in the code example is wrong. In the documentation, not the code example, it says enter image description here

    You see fieldName and order are string, not Array<String>. Also, fieldName's supported values include _createdDate but not createdDate.

    Try changing the parameter to

    { fieldName: '_createdDate', order: 'ASC' }