Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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' }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading