@jonatandor35 Thank you, that was the error i was making!
For everyone else; this is the working code snippet to change the internal WIX uri to the URL fetchable for apps and other places in the net and make images accessable. It is in the http-functions.js file:
export function get_stories () {
let options = {
"headers" : {
"Content-Type" : "application/json" ,
"Access-Control-Allow-Origin" : "*"
}
};
**return** wixData . query ( "Stories" )
. find ()
. then (( results ) => {
let items = results . items ;
if ( items . length > 0 ) {
items = items . map ( e => { e . mainImage = `https://static.wixstatic.com/media/ ${ e . mainImage . split ( '/' )[ 3 ]}`; **return** e ; });
options . body = {
"items" : items ,
}
**return** ok ( options );
}
})
// something went wrong
. catch (( error ) => {
options . body = {
"error" : error
};
**return** serverError ( options );
});
}
Note that mainImage is the field key in the database where my images are stored.
@J.D. i would like to know what the logic behind this line is. Can you help me?
https://static.wixstatic.com/media/ ${ e . mainImage . split ( '/' )[ 3 ]}