Fetching data from API for ReasonReact app - fetch

I'm learning ReasonReact and I would like to fetch data from a API, that I'm going to use on my component. However, on the official website about Reason or ReasonReact there's nothing about this, neither I found something searching on Google. How can I do it?

You can use the existing bindings to HTTP client libraries, e.g.:
https://redex.github.io/package/bs-fetch
https://redex.github.io/package/bs-axios
The former works in browser only, the latter works in both browser and Node.
In general, if you're looking for a way to do something, Redex is a great place to look.

Related

GET request updating 'seen' status

First of all, I am aware of the details mentioned in the HTTP 1.1 specification saying GET requests should be idempotent, and it all makes total sense to me. I'm always using POST requests for login/logout, form updates and everything that changes the state of my web app, but I have a problem with one particular scenario.
Imagine you're displaying a list of user's notifications, and you want to update the seen status once they've been rendered into html. The simplest solution is to perform an update of the model instances during the GET request, but that's where it would break HTTP 1.1 specs. Not only it would not follow the specs, but I'm also concerned about url prefetching and automatic GET request retry in some browsers, and maybe other possible scenarios.
Doing it using AJAX also doesn't seem like a good enough solution to me, because I would like the web to also work correctly with JS disabled.
The site also has an API for iOS/Android, but there it can be easily solved in multiple ways which seem right to me, so that's not a problem.
Did you guys come across any similar problem to this and found a way to handle it? I can't seem to find a good solution to this problem. Any help is appreciated.
Ok, so I think I found a solution which makes sense. I'm going to implement the AJAX solution (POST) + a 'Mark all as read' button (POST) as a fallback for the edge case.

Grab Xbox live friends list from bungie

Hey all, I'm trying to grab and display a friends list from bungies friends list.aspx file:
https://www.bungie.net/Stats/LiveFriends.aspx
and display them in a desktop application.. VB or something
How would I be able to do this? Does it have anything to do with asp? Are there any tutorials that can show me how to grab and display information?
If you're really interested about consuming information from Xbox Live, you can apply for the XBL Community Developer program from free here: http://www.xbox.com/en-US/community/developer/
There you'll be provided with API access that will be quicker and more reliable then parsing data from the Bungie site.
You'll need to fetch the data ("scrape" it) through something like a WebRequest. That will give you the raw HTML or whatever it outputs.
I'm sure, without even looking, that it uses some kind of login as well, which you will have to support. I would guess that involves making a request with the credentials to some page and extract the cookie returned which you will have to pass around. The cookies are passed around as headers.
The first thing you'll have to do is examine the HTML returned and determine how to process it to get the information you want. I would use Chrome and it's excellent developer tools for this, or another browser like Opera or Firefox with similar capabilities. This will also work for figuring out how to handle the session cookie.
Maybe 360voice can help? Haven't looked at the API enough to know if it has what you need.
http://360voice.gamerdna.com/forum/topic.asp?TOPIC_ID=3

Best practice to implement back functionality in flex

I'm not using deep linking, so all the pages/states appear as http://site.com
Is it still possible to implement back functionality in this case? It looks like flex has a browser history feature, but not sure if it would still work given that all the pages are at site.com
The other option is that I would save information in the main file itself so I can go to the last page and retrieve whatever data was on it.
Anyone can advise what's generally the best practice way to handle back functionality?
Unfortunately I don't know of any other way to implement browser history (ie, back/forward) without using deep linking (eg, example.com/#foo). This is how the Flex browser history components implement it.
However, one thing you could do, if you need to keep the URL static, is stick your Flex application in a frame. That way the outter frame would still show example.com while the inner frame is at, for example, example.com/#widget=42.
Check out the Flex docs on Deep Linking and the Browser Manager.
The best practice and generally the only way to do it is to use deep linking.
it's best because the users can add a section of your application to "Favorites" and that's an important feature to have IMHO.
Do you need to keep your website with just http:// site.com or is that just how it looks now because deep linking is not implemented?
Checkout Angela's Accessible Rich Internet Application tutorial which gives instructions on how to quickly and easily set up deep linking using UrlKit. The added bonus of this site is that the tutorial is delivered in the environment described... IE: you can view the source for an "in production" example of the implementation.

dashcode and external rss feeds

I was wonder if anyone can help me with this. I've been looking everywhere for this information, but I want to make a web application using dascode rss. I know that you can't link external sources. Does anyone know a way I can get around it. From what I understand a little php can get around this, but I'm unsure where to look.
OK, first thing no PHP. Dashcode is limited to HTML, CSS and JavaScript. Although having said that there are a whole range of system calls that cna be made using the functionality provided by various parts of the x-cde system.
Second yes you can link to external sources such as other web sites, api on say Twitter, google etc. RSS feeds and so on, not sure where you got the idea to the contrary.
If you want to learn how to do a Dashcode RSS then open up Dashcode, start a new project, either web based or Dsashboard based and choose the RSS project. This will give you an out of the box template to add you own information and then see how it works. Then customise it.
In the above i am assuming Snow Leopard and the latest Dashcode/X-code but it will still gove you most of what you want on earlier version.

how to design a game web app?

i know vb.net, but have had no experience at all with web programming. i need to make a web app that can run in a browser where there is a board game and pieces that you can move around. can someone help me get started? are there any examples in asp.net?
i need something like this:
http://www.hallofbrightcarvings.com/game/grid
i don't know what language this is built in, but i would much prefer vb.net. i would like the pieces to be pictures instead of text. please help get started.
I have a very basic example of moving pieces around a grid written in javascript.
You can see it in action here and if you take a look at the source you can see it's done with jquery mostly. Feel free to take a prod around, I haven't updated that version in a long time but hopefully you might find it useful.
I think ASP.NET can do very little for you according to what you described. What you need is either Flash or Javascript skills.
Let's decompose this, you need two things if you want to make the whole thing yourself
Client Side: Flash, SilverLight, JAVA
Server Side:PHP, ASP.net, Java
As you know vb.net and want to work with asp.net, so I recommand to use Silverlight.
How complex can this be?
Depends on what you want to build, if you want to build a Mafia war games, then you'll need to work the user interface and it'll be very hard. Also the server side will be important as you need to handle registration and relation between different players.
If you specify more your question, you could get better answers.
The example you cited above is fully client-side, which means the code all sits on the browser and the server doesn't do anything to enable the grid. So if you did a "Save As" of that page on your computer, you could run it offline.
You should use the view source functionality of your browser on the page you cited, and look at how it's built. It's done using HTML, CSS and javascript. Use w3schools to get yourself started on those three matters.
If you really need to code it using vb.net, I don't know of any way that allows drag-and-drop for web forms. I'd be interested to know though. Ajax and .net drag-and-drop should be keywords for you to look into.
To do this on the web, you'd probably want to divide the project into two components: Client-side and server-side.
On the server-side, you'll want to use language like PHP, Python or ASP.NET. I think ASP.NET has some way to use VB.NET, so that would be a good choice for you to minimize the number of new things you need to learn.
Client-side is going to be the big hurdle. There's basically two different approaches to take here:
HTML+CSS+Javascript, using HTTP callbacks (ie, AJAX) to communicate with the server.
Flash using Flex (I think HTTP calls is probably the easiest way to talk to your server here as well.)
For a game like that, I would think that Flash is probably the best way to go. It will be easier to do graphics and sounds, and it'll run the same in every browser that has Flash support.

Resources