Saturday, November 17, 2018

Things that are hard: trivial POST request from the browser

I'm trying to make a trivial web app. Why is this so hard?

Glitch is an amazing site for making this, but its "simple node app" example does not POST anything back to the server.

I finally got this working. Here's the result -- it might be useful to you to remix it.

https://send-json-post.glitch.me

Things I figured out:
  • add the json middleware to express
  • some library to post from the client. I used axios because it's what we use in our apps. This is probably not the simplest one
  • browserify middleware to be able to install it from the client
  • the Chrome developer tools, alt-cmd-I on a mac:
  • you can see the request headers in the network tab if you click on the request of interest and then scroll down in the right place.
  • to play with things in the console, like trying to make a POST request: find the script under "sources". put a debug point where you need access (like in my case, I needed axios, so I put it at a place where I used it). Then in the "scope" section of the debugger, find that variable, right-click on it, and save as global. It appears as "temp1" in your console. Don't forget to push play to make the debugger let go. The global variable stays available and you can call "temp1.post(...)" etc to figure out what you're doing.

Then getting anything to update in the front end, that was hard too. I'm definitely going to bring in a front end framework before I try to do anything further.

10 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. Good post. I was searched this topic. Finally I got the information in this blog. Thanks for posting such a nice article.- seo company in chennai

    Web Rifer Technologies

    http://www.webrifer.com/seo.html

    ReplyDelete
  5. Amazing things in this post that are hard trivial post, thanks for sharing...
    Furnace Manufacturers in India

    ReplyDelete
  6. Nice article.Really it is informative and useful. Thanks for sharing this blog. - seo services in chennai


    Web Rifer Technologies

    http://www.webrifer.com/seo.html

    ReplyDelete
  7. I am reading a blog on this website for the first time and I would like to tell you that the quality of the article is up to the mark it is very well written. Thank you so much for writing this article and I will surely read all the blogs from now on. Thank you so much for caring about your content and your readers. Contact us for QuickBooks Support Phone Number and QuickBooks Payroll Support Phone Number.

    ReplyDelete
  8. Awesome blog. Really it is an interesting and informative article. Thanks for sharing this post. - seo company in chennai

    Web Rifer Technologies

    http://www.webrifer.com/seo-company-in-chennai.html

    ReplyDelete
  9. Business Law Assignment Help
    https://www.msahomeworkhelp.com/Get-Excellent-Help-For-Business-Law-Assignments-To-Excel-In-Studies.html

    ReplyDelete