pexeixv
pexeixv

Reputation: 115

How to get obtain redirected link using JavaScipt?

I'm trying to access Unsplash Source to get random images. When you open the link https://source.unsplash.com/random, you get redirected to a random image with a random link as follows https://images.unsplash.com/photo-1614607660006-945b019c188a?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max

Is there any way I can obtain the random redirected link ie something like https://images.unsplash.com/photo-1614607660006-945b019c188a?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max? Because I need to store it in a variable.

Upvotes: 0

Views: 73

Answers (1)

pexeixv
pexeixv

Reputation: 115

My main issue was not getting random images because the browser caches the requests made to the same URL. I solved it by following this comment on Github. https://github.com/unsplash/unsplash-source-js/issues/9#issuecomment-239053606

Upvotes: 1

Related Questions