Instead of logging a response, my one server-side ...
# prisma-whats-new
m
Instead of logging a response, my one server-side subscription function (“when a file is uploaded, upload it to cloudinary, an image hosting provider”) appears to be logging:
Copy code
"returnValue":{"rawResponse":{}}}
Might anyone know why? Code:
Copy code
const cloudinary = require('cloudinary@1.2.1')

module.exports = function (event) {
  cloudinary.config({ 
    cloud_name: '___CLOUD_NAME___', 
    api_key: '___API_KEY___, 
    api_secret: '___API_SECRET___' 
  })
  console.log('Received event')
  cloudinary.uploader.upload(event.data.UserAvatar.node.file.url, (result) => {
    console.log(result)
  })
}
Referring to
console.log(result)
at end.
cloudinary
receives images alright. But I don’t seem to be receiving a response. And inserting
return result
also doesn’t appear to work.
n
@martin this is due to the callback API that
cloudinary.uploader.upload
uses. Graphcool Functions don't support callbacks, only promises: https://www.graph.cool/docs/reference/functions/overview-boo6uteemo/#current-limitations
👍🏽 1
m
Thanks for the clarification, @nilan.
n
You can "wrap" the callback function with a new promise. Actually, could you ask the same question in our forum: https://graph.cool/forum/c/development? My answer there will be helpful to many developers 🙂
m
Argh, the forum 😀 Slack is so much more addictive 😀
😹 1
Will do.
n
Thanks 🙌
m
That worked, thanks!
🎉 1
n
sounds like a new PR to the functions repo 🤔
😂
m
😀 Yes yes yes… you gotta train me to think like a developer!
n
haha!
I'm about to review your current PR, I should do that first haha
🙌🏽 1
No worries if not before the weekend—I’ll figure it out. Thanks Nilan!
n
just got back!
🦜 1