Im learning asp.net mvc and Umbraco on this moment.
Now Im trying the following.
I have to read some pictures from a external api and place them on the front-page. There are a lot some 2000
I have to do three steps to make this work.
1) Get all the images numbers from the external api.
2) With that number I can ask on another url for the image data like the author,
3) With that number I can ask on yet another url for the image so I can post it.
Where do I put the code that calls all the data and what is the most efficient way to make this all work so it will not take hours to get all the data.
where do I put a call to a external api
Hello,
Im learning asp.net mvc and Umbraco on this moment.
Now Im trying the following.
I have to read some pictures from a external api and place them on the front-page. There are a lot some 2000
I have to do three steps to make this work.
1) Get all the images numbers from the external api.
2) With that number I can ask on another url for the image data like the author,
3) With that number I can ask on yet another url for the image so I can post it.
Where do I put the code that calls all the data and what is the most efficient way to make this all work so it will not take hours to get all the data.
Hi Roelof,
Welcome to Our!
It looks like the best way to get images will be some external worker, ot just check on the start of application do you have images locally or no.
If no - download them asynchronously.
If you need image per page - another solution will be download image per page when page will be requested, look at RenderMvcController - https://our.umbraco.org/documentation/reference/routing/custom-controllers
The main question how will you show images on the site?
Thanks,
Alex
Hallo,
Thanks for the help. I like to display 10 images aan page because the api sends that number on every respons
The image is also a link to a detail page
Roelof, is your api slow? Should you call api async or no?
Thanks
The api is not slow but ik need to make 3 request every image.
1 request retrieving the image number so for 4700 there wil be 470 request.
Then for every image i need to do 2 request. One for the image andere one for the image data
Roelof, I think you need to download all images, if it's possible to your local machine and show from local.
Or call api asynchronously, it will be faster.
Oké, so first make a request for the 10 numbers and then in the response ask for the other two. So nest three async request
Yes, try it, how many time it will take.
Hi Roelof,
Did you solve the problem ?
Thanks
Nope, still figure out how the async stuff works and im now on holiday so no box for development right now
So what is the answers for where to put the code to call external API to get data ?
Thanks.
Hi Wilson
Try to put your code to App_Code folder or if it's Web Application project - Controllers folder.
Can you share what code are you using?
Thanks,
Alex
is working on a reply...