Problem With Backend

I’m just trying to pull a very simple url with Wix Media Backend API (getFileUrl) but it doesn’t work like I want. I can’t pass incoming URL into object it just pass undefined. I also console.log incoming URL and I can see there is URL it’s working but it doesn’t pass this URL into object here is the backend code. Just spent 6 hours for this very stupid thing and still can’t understand why it’s not working.

All I want to do is create my own Orders page but it’s being impossible to create because nothing is working like I want.

getFileUrl - Velo API Reference -

Here is the backend code: (I made the problem code black and bold)

import wixData from 'wix-data'
import { mediaManager } from 'wix-media-backend';

export async function getOrders(memberId) {
    let options = {
        "suppressAuth": true,

    return wixData.query("Stores/Orders")
        .eq("", memberId)
        .then((orders) => {
            if (orders.items.length > 0) {
                let orderData = orders.items;

                return wixData.query("Products")
                    .then((products) => {
                        if (products.items.length > 0) {
                            let productsData = products.items;

                            return, index) => {
                                let orderData = {
                                    "_id": order._id,
                                    "formattedAddress": order.billingInfo.address.formatted,
                                    "paymentMethod": order.billingInfo.paymentMethod,
                                    "memberLastName": order.buyerInfo.lastName,
                                    "memberFirstName": order.buyerInfo.firstName,
                                    "orderDate": order._dateCreated,
                                    "orderNo": order.number,
                                    "lineItems": [],
                                    "paymentStatus": order.paymentStatus,
                                    "totals": order.totals

                                orderData.lineItems = => {
                                    let lineItem = {
                                        "productDownload": undefined,
                                        "productQuantity": lineItemData.quantity,
                                        "productSku": lineItemData.sku,
                                        "productPrice": lineItemData.priceData.price,
                                        "totalPrice": lineItemData.priceData.totalPrice,
                                        "options": lineItemData.options,
                                        "customTextFields": lineItemData.customTextFields,

                                    productsData.forEach((product) => {
                                        if (product.productId._id === lineItemData.productId) {
                                            let now = new Date();
                                            let gap = now.getTime() - order._dateCreated.getTime();

                                            if (product.productId._id === lineItemData.productId && gap < 31556952000) {
                                                if (product.productDownload) {
                                                    let start ="archives/") + 9;
                                                    let end =".zip") + 4;
                                                    let fileName = product.productDownload.slice(start, end)

                                                    lineItem.productDownload = mediaManager.getFileUrl(fileName);

                                    return lineItem

                                return orderData;
        .catch((err) => {

As you can see there is no problem when I test it I’m getting all data except downloadUrl (I tried passing data after .then also not working I tried everything) please someone tell me why this API not working like I want it’s not passing the data here is test results:

result is Empty object for URL

Here is the console log for url and it’s actually exist but didn’t pass the url inside.

Result is coming first console log

You’re nesting the promises instead of chaining them, and it makes it hard to read (and hard to handle).
Please chain them:

return PromiseA()
.then(r => {
    return PromiseB();
.then(r => {
    //..some code
    return something;
.catch(err => err)

And post it again (+ use darker colors for you code text). Thanks

Colors are coming from Velo colors in dark mode next time I will copy on light mode but about nesting yes it’s hard I should change it I will post the code again

1 Like