Dark Sky API data shown in Chrome/Safari but not on Phone (Ionic 2) - api

I've been testing to get weather data from https://api.darksky.net/.
After research, in my provider, where I use this.http.get, my codes are as below:
let url = 'https://cors-anywhere.herokuapp.com/https://api.darksky.net/forecast/a470b5427c601724577e80b8bc4d2d03/37.8267,-122.4233'
let response = this.http.get(url).map(res => res.json());
return response;
It shows on Chrome/Safari, and you notice my url added something 'https://cors-anywhere.herokuapp.com/'. It is successful, very very good. I show you the image:
See, I have the temperature and summary. Location I use Google API that's why no mention.
Okay, real problem here. I ionic upload and I want to see it in Ionic View. Tom my very surprise, it shows no data, except the clock and the word "in". I removed https://cors-anywhere.herokuapp.com/ it also seems useless. Still nothing. Can you guys please help me?
I really really thank you.
*No one replied me :( But it's okay, what if it is in React Native?

The HTTP method is asynchronous. You haven't really provided an awful lot to go on here in terms of how you're actually displaying the data, but this is how I'd go about it.
this.http.get(url)
.map(res => res.json())
.subscribe(data => {
console.log(data); //here's your response
return data;
});
As I said, this is asynchronous, so I'm not sure whether you know that when you return response above. That's why I put in the console.log line so that you can see that it's getting back data.
Bear in mind that darksky also has rate limits. I think it's 1000 free calls a day, and then it's into a paid tier. So if you've been bombarding their server without any payment details, then you'll get cut off.

Related

How Do I Create a Custom Error Response in Zapier

I am creating a new App for our customers to use. However, I am having a hard time finding any documentation on properly responding with error codes back to Zapier in the event something goes wrong.
One example I have, is a new customer creates a Zap and when attempting to look up data from our API, we have no data to return to them just yet.
It took me a while, but using the 400 HTTP header got me a little closer. But in this example, you can see, I just get a basic text response back. I know I'm logged in as Admin, so it will look different. However, without a doubt, I'm sure I need to format the response Object, so Zapier can lay out my error text like the second example.
I am hoping to replicate what Google Sheets has done below and specify the response, so the user knows what the issue is.
you can do something like:
if (resp.status != 200) {
throw new z.errors.Error(`Something went wrong.`);
}
You can read further here

Facebook graph API can't break down by asset

I'm trying to get a breakdown at image and video asset level with Facebook graph API, but whenever I add image_asset or video_asset the response becomes empty, is there anything I am doing wrong or is there some API limitation I should know about? I can't find anything in the docs:
With country breakdown it works fine but when I switch to image_asset or video_asset I get a response like this:
{
"data": []
}
After discussing with FB we have solved a similar issue on our end. Perhaps it is the same for you: It can happen that a campaign in settings has 'dynamic creatives' turned off - in this case no data will be returned by the dynamic creative breakdown (as there is no data), but other breakdowns will provide data, which seems like it is the case for you. You can solve it by just retrieving ad data and then getting the creative data you need related to this ad. Hope this helps!

Coinbase Webhooks: is there a list of all data available?

I am looking into the webhook notifications and I am struggling to find documentation...
I would need to find the different payload for the "data" in the notification response...
the documentation only have one example: https://developers.coinbase.com/api/v2#show-a-notification
it is almost impossible to built an app if I need to try and see every type of notification by myself... (trial and error approach :( )
any extra resource? any help here?
thank you all
On this page, there is a link that says
See full list of notifications and corresponding payload information
But guess what, it links to the pages in your OP.
Even CB's newest documentation doesn't outline the payload until you run a sample to get the result displayed in the docs page. Here is a simple example, just click Try It to see the payload. It's not a bad thing until you need to see the payload of a signed request, then it's a PITA...
I've never used their webhooks to know how the payload differs but considering their docs you may need to run each notification to see what to expect and save the result to refer to later.

Quizlet API not available

I’m not sure if this is the right place to ask this but I’m trying to use the Quizlet API for a personal project I have but I can’t seem to find where to access the Quizlet API. It seems like there are a few pages on Quizlet about their API but all of them are now gone giving “The page you’re looking for is no longer available error”.
I’m just wondering if anyone knows how I could get the API key (I am relatively new to working with API’S).
They are no longer supporting the API.
The answer from the support:
Thanks for your interest in the Quizlet API. We are no longer supporting the Quizlet API, for commercial or personal use, and are not currently issuing any new API keys to potential developers.If you would like to be contacted about any future updates, please let us know by filling out this form: https://docs.google.com/forms/d/e/1FAIpQLScxmhsrGJGbnf0Y0qh9FiquWyDLiWZozc2aKcqczFL2SvYMvw/viewform
Seems that API is hosted at a different URL and may be working at this time. Here's a snippet that came up on google search and seems to be active.
https://www.thiscodeworks.com/get-quizlet-flashcards-via-api/61bbc4382e046e00150bd05b
async function quizlet(id){
let res = await fetch(`https://quizlet.com/webapi/3.4/studiable-item-documents?filters%5BstudiableContainerId%5D=${id}&filters%5BstudiableContainerType%5D=1&perPage=5&page=1`).then(res => res.json())
let currentLength = 5;
let token = res.responses[0].paging.token
let terms = res.responses[0].models.studiableItem;
let page = 2;
console.log({token, terms})
while (currentLength >= 5){
let res = await fetch(`https://quizlet.com/webapi/3.4/studiable-item-documents?filters%5BstudiableContainerId%5D=${id}&filters%5BstudiableContainerType%5D=1&perPage=5&page=${page++}&pagingToken=${token}`).then(res => res.json());
terms.push(...res.responses[0].models.studiableItem);
currentLength = res.responses[0].models.studiableItem.length;
token = res.responses[0].paging.token;
}
return terms;
}

Parse.com want to redirect to get from post

I am new to Parse, and am still trying to understand routing. So please bear with me if this is a dumb question.
Please visit their tutorial:
https://www.anyimg.org/i/QDn6jGX6Lz
On this page, I am trying to add a simple comment. When I click submit, I want to display the exact same page, but with the comment(s) displayed on the bottom.
Thus far, I can only do some simple redirects upon submit. But I think I really need to be able to reconstruct a new app.get and redirect to this exact same mount.
I tried something very basic like this (to just display the original get), but even that does not work.
app.post('/:id', function(req, res) {
var id = req.params.id;
// Build the query to find an image by id
var query = new Parse.Query(Image);
query.equalTo("objectId", id);
res.redirect('/i/:id');
});
So my questions are:
I saw somewhere that you can call an app.get from within app.post, but no matter how much I searched, I could not find that example again.
I want to create a comments table in Parse and track it by user name (I realize that I am asking for a mini tutorial here).
Any help will be appreciated.
Thanks!
Proper routing/redirects: app.post('/:id', function(req, res) { var id = req.params.id; res.redirect('/i/' + req.params.id); I did not have the "+" originally.
I got this mostly done as well
a. Add a post form in show.ejs.
b. Make sure that the encoding of type application/x-www-form-urlencoded.
I think you need that period at the end of the type. At least
Webstorm forced me to add it. JSON encoding may also work, but I gave up after just a couple of attemts since Webstorm did not "buy" my syntax.
c. http://www.parse.com/docs/js/symbols/express.html#.bodyParser Like
this: app.use(express.bodyParser()); You can include just inside the
post as a local, without the need to break anything else
d. I then created a new copy of the Image object (Image table in the
DB), and simply set the comment in one of the columns
e. Ideally, you want to set up a comments table, to capture comments
by user. But I don't have time to try that.
Note: Make sure the ACL permissions for each user is set correctly in the Image table. That's what got me. It allows anonymous users to post. To prevent this and make everybody log in first, this, see my other post:
Parse.User.current(), globals etc