[SOLVED] Fetch Image with Full Url

I solved it like a different way. the following code does a few things, one it opens the api for the databases you whitelist, it hides all data that is hidden in the database, it displays the url link of images instead of the wix-media link. so no conversion is needed. then it adds the the link to the urls it displays.
id like to add groups and messages and such thinks like posts to that, with oath requests attached to the header of the request, but i haven’t figured that out yet. hope this help you.

import { ok, badRequest } from ‘wix-http-functions’;
import wixData from ‘wix-data’;

// Function to convert the Wix image URL to an external accessible URL
function convertWixImageUrl(wixImageUrl) {
if (wixImageUrl.startsWith(‘wix:image://v1/’)) {
let convertedUrl = wixImageUrl.replace(‘wix:image://v1/’, ‘https://static.wixstatic.com/media/’);
const match = convertedUrl.match(//([^/]+)$/);
if (match && match[1]) {
convertedUrl = convertedUrl.replace(match[0], ‘’);
}
return convertedUrl;
} else {
return wixImageUrl;
}
}

// Function to recursively convert Wix image URLs in an object
function convertWixImageUrlsInObject(obj) {
for (let prop in obj) {
if (typeof obj[prop] === ‘string’) {
obj[prop] = convertWixImageUrl(obj[prop]);
} else if (typeof obj[prop] === ‘object’) {
convertWixImageUrlsInObject(obj[prop]);
}
}
}

// Making a common open API for your data collections in Wix Code
// so other systems can consume your data
// Type in the Data Collection names you do allow to be a part
// of the common API functions (change each ‘database’ for your name of your database on query side ie: ’items’
let whiteList = [‘Database1’, ‘Database2’, ‘Database3’, ‘ECT…’];

export function get_api(request) {
const response = {
headers: {
‘Content-Type’: ‘application/json’
}
};

// Get name of Data Collection from path[0]
let datacollection = request.path[0];

// DummyData
if (whiteList.includes(datacollection)) {
return wixData.query(datacollection)
.limit(1000) // You can set a reasonable limit here for performance reasons
.ascending(‘title’) // Sort alphabetically by title in ascending order
.find()
.then((apiResults) => {
if (apiResults.totalCount > 0) {
// Convert Wix image URLs in the response before sending to the client
apiResults.items.forEach((item) => {
convertWixImageUrlsInObject(item);
});

      response.body = {
        items: apiResults.items
      };
      return ok(response);
    }

    response.body = {
      items: "No items found in the collection."
    };
    return ok(response);
  });

}

response.body = {
error: “Data Collection is not allowed to be used through this API.”
};
return badRequest(response);
}

Hope. this helps anyone following this.