I am currently exploring the possibility of utilizing ProductHunt's API to perform basic get requests. The API mandates a token and redirect URI for access. However, when attempting to retrieve posts by applying the provided ApiKey and URI, I find myself redirected to the specified URI without receiving a JSON object in return. How should I structure a getJSON or AJAX request in this scenario?
Upon making a straightforward JSON request in my browser, I am faced with numerous unsuccessful responses. My primary goal remains to obtain their JSON data to navigate through posts, yet I am uncertain about devising a URL retrieval method that avoids redirection.
Here is the current code I have for a simple request:
var query_params = { client_id:'[my apikey]' ,
response_type:'code',
redirect_uri:'[my URI]',
scope:'public+private',
};
$.ajax({
url:'https://api.producthunt.com/v1/posts',
type:'GET',
data:query_params,
crossDomain:true,
dataType:'jsonp',
success:function(data){
console.log(data)
},
error:function(){
console.log('Failed!');
}
});
How should the request URL be structured to effectively access their JSON object? Additionally, what elements might be missing from the existing code snippet above? Any assistance on this matter would be greatly appreciated. Thank you!