Jarl Gjessing
Posts: 0
Joined: Sat May 02, 2015 2:26 pm

decode response from file api after upload

I have successfully uploaded a file to the file api.
And console.log(data) say:
success
Object { filename="cc0ef18b-2301-4223-86cb-35b90d51e382.betaling.pdf", fileurl="https://api.appery.io/re...b90d51e382..."}
filename

"cc0ef18b-2301-4223-86cb-35b90d51e382.betaling.pdf"
fileurl

That is all and well, but how can I read the filename?
Sorry for the noop question

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

decode response from file api after upload

Hello,

I am sorry, not sure I understand you correctly. Please specify your question.

this is filename:"cc0ef18b-2301-4223-86cb-35b90d51e382.betaling.pdf". What do you need to get?

Jarl Gjessing
Posts: 0
Joined: Sat May 02, 2015 2:26 pm

decode response from file api after upload

Hi, thanks
Well, I see the filename :-) I just want to be able to gain access to the variable in the object.
So, I tried json.stringify(data) to output the object, that returned the object as a string just fine. Then I tried data.settings, and I got undefined.
So my question is in "Run Javascript" in Appery, how to I get access to the objects variables? Image

Here you see the "Run JavaScript" code.
The alert contains:
Your file was successfully uploaded with id: [{"success":{"filename":"b707fbd0-b67f-4340-959d-c41ae2aa8b94.betaling.pdf","fileurl":"https://api.appery.io/rest/1/db/files..."}}]

So I try to do data.success or data.filename both returns undefined :-(

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

decode response from file api after upload

Hi Jarl - Could you please re-attach the image to your post.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

decode response from file api after upload

Could you please also show the exact returned object that you're getting?

Jarl Gjessing
Posts: 0
Joined: Sat May 02, 2015 2:26 pm

decode response from file api after upload

Sorry, figured it out I think.. It's an array,that is why I could not access it directly. To get access I need to write: data[0].success.filename

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

decode response from file api after upload

Yes, you are right Jarl! Glad everything is OK now.

Return to “Issues”