Thanks, this is my updated function:
Moralis.Cloud.define("fetchJSON", async function(req) {
let test = req.params.theUrl;
await Moralis.Cloud.httpRequest({
url: 'https://ipfs.moralis.io:2053/ipfs/Qmf9Ck4JhiyWeDzbJtXQufjbankmd5Tzhr8JXCZ7wQ6iWR/test/0.json'
}).then((res) => {
logger.info(res.text);
return res.text;
}).catch((err) => {
logger.info(err);
})
});
The cloud function seems to work fine because my logger.info() returns the correct information (what I am expecting)
But on the front end when I do a console.log() with the response I get undefined.
This is the code I use in the frontend:
const cloudMeta = async(_uri) => {
let params = {theUrl : _uri};
const metadata = await Moralis.Cloud.run("fetchJSON", params);
console.log(metadata);
}
<button onClick={() => cloudMeta('addUrlLater')}>fetch info</button>
EDIT: in my cloud function console I have the following:
2022-07-22T20:43:49.032Z - Ran cloud function fetchJSON for user J6m8NuJxsONa6WhhHdBmjrod with:
Input: {"theUrl":"https://ipfs.moralis.io:2053/ipfs/Qmf9Ck4JhiyWeDzbJtXQufjbankmd5Tzhr8JXCZ7wQ6iWR/test/0.json"}
Result: undefined
2022-07-22T21:09:50.723Z - {"eventName":"test","eventDate":"2022-07-22T17:16:49.791Z","eventLocation":{"value":"FR","label":"France"},"NumberOfTicket":"100","attributs":{"attribut":"10"}}
as you can see the first log shows result as undefined which explains why in fmy front end I have undefined but the second log shows the json I am expecting to get which means the http request works correctly.
I am kinda lost ngl