One place for hosting & domains


      Use ExpressJS to Get URL and POST Parameters

      While this tutorial has content that we believe is of great benefit to our community, we have not yet tested or
      edited it to ensure you have an error-free learning experience. It’s on our list, and we’re working on it!
      You can help us out by using the “report an issue” button at the bottom of the tutorial.

      Often when we are building applications using ExpressJS, we will need to get information from our users.

      This can happen any number of ways but the two most popular are:

      URL Parameters

      These are information that are passed through the URL like so:

      This is most seen in requesting information from an API.

      URL Parameters are grabbed using req.param.variable_name

      POST Parameters

      These are information that come from forms. We’ll be grabbing from forms that pass information as application/x-www-form-urlencoded.

      POST Parameters are grabbed using req.body.variable_name

      Let’s take a look at how we can grab the parameters using the popular Node.js framework, ExpressJS.

      Sample App to Test

      We’ll be creating a sample application to make sure that grabbing parameters works. We’ll also be using POSTman to test the form POST.

      We’ll only need two files:

      - package.json
      - server.js

      Here is the package.json

          "name": "express-parameters",
          "main": "server.js",
          "dependencies": {
          "express": "~4.10.2"

      Here’s the start of our server.js:

      // grab the packages we need
      var express = require('express');
      var app = express();
      var port = process.env.PORT || 8080;
      // routes will go here
      // start the server
      console.log('Server started! At http://localhost:' + port);

      We can now start our server using:

      You will have to restart the node server every time you edit server.js. If this gets tedious, see how To Restart Your Node.js Apps Automatically with nodemon.

      Now let’s create two routes now to test grabbing parameters.

      Getting Any URL Parameter

      For this example, we’ll grab a parameter directly from the URL. Let’s say we are using the example URL:

      The parameters that come out of this will be:

      id: 4
      token: sdfa3
      geo: us

      It’s very easy to grab these parameters. Here’s the route and the method for grabbing parameters is req.param().

      // routes will go here
      app.get('/api/users', function(req, res) {
          var user_id = req.param('id');
          var token = req.param('token');
          var geo = req.param('geo');  
          res.send(user_id + ' ' + token + ' ' + geo);

      The parameters are naturally passed through the req (request) part. Now if we go to our browser at http://localhost:8080/api/users?id=4&token=sdfa3&geo=us, we’ll be able to see the three parameters!

      Specific Routing for Specific Parameters

      We can also name the paramter directly in the route itself. Here’s a URL and example:

      // http://localhost:8080/api/1
      app.get('/api/:version', function(req, res) {

      Route Parameter Middleware

      Next up, we’ll be using the Express param function to grab a specific parameter. This is considered middleware and will run before the route is called.

      This can be used for validations (like checking if a user exists) or grabbing important information about that user or item.

      An example for this would be:

      // parameter middleware that will run before the next routes
      app.param('name', function(req, res, next, name) {
          // check if the user with that name exists
          // do some validations
          // add -dude to the name
          var modified = name + '-dude';
          // save name to the request
 = modified;
      // http://localhost:8080/api/users/chris
      app.get('/api/users/:name', function(req, res) {
          // the user was found and is available in req.user
          res.send('What is up ' + + '!');

      If we visit the URL in our browser, we’ll see:

      What is up chris-dude!

      Pretty neat. You can use this param middleware for validations and making sure that information passed through is valid and the correct format.

      We then save information to the request (req) so that our other route will have access to it.

      Further Reading More Express routing: Learn to Use the Express 4.0 Router

      POST Parameters

      To get POST parameters, we’ll need two the ExpressJS body-parser package. This will allow us to grab information from the POST.

      Install body-parser

      We’ll need to install body-parser using:

      • npm install body-parser --save

      Now that we have that package and it has been added to our package.json thanks to the --save modifier, we have to configure it in our server.js file.

      Add the following after you define the app variable.

      var bodyParser = require('body-parser');
      app.use(bodyParser.json()); // support json encoded bodies
      app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies

      With body-parser configured, we can now create our route:

      We will grab POST parameters using req.body.variable_name

      // POST http://localhost:8080/api/users
      // parameters sent with'/api/users', function(req, res) {
          var user_id =;
          var token = req.body.token;
          var geo = req.body.geo;
          res.send(user_id + ' ' + token + ' ' + geo);

      We can test this using POSTman and send information as application/x-www-form-urlencoded:


      Those are the quick ways we can grab information using ExpressJS. Grabbing data from the request is an easy enough process.

      Just grab the information quick and easily so that you can move on to building great things!

      Source link

      How to Write a Blog Post: A Step-By-Step Guide

      1997: the year the Pathfinder landed on Mars, Madeleine Albright was sworn in as Secretary of State, and Titanic demolished box office records.

      It’s also the year the term “weblog” was officially coined (even though the first blog is said to have existed in 1994, at the near genesis of the internet). For two decades, starting a blog has been a powerful way to connect with internet audiences and share creative content.

      Yet, with blogging’s established rep as a powerhouse (and dominant) form of web content, it’s easy to witness the ever-changing and ephemeral landscape of the internet. Blink and virtual crowds have abandoned one novelty social media platform for another. Viral memes and web fads frequently give internet audiences virtual whiplash. Content creators are fighting to garner the ever-depleting attention spans of web users.

      So are the web’s 31.7 million blogs losing relevance anytime soon?

      Not at all.

      It turns out 77% of internet users read blogs regularly. What’s more, 61% of Americans spend three times the amount of time-consuming blog content than they do email content.

      Blogging is still very much a crucial part of a thriving brand and a next-level content marketing strategy in 2020. Whether you’re a brand or a business, you want to attract traffic and offer something of value to visitors. Blogging is a major key to that engagement — having a blog on your website increases your chances of ranking higher in search engines by a massive 434%. Plus, bloggers wield immense influence on the web — giving your brand the opportunity to grow in a big way.

      So do you have everything you need to be a blogging success? Let’s find out. Passion? Check. Website? Check. Fueled by a great *ahem* web hosting company *ahem*? Double-check. You’re ready to share your own unique content with the world wide web.

      Power Your Blog with DreamHost

      We’ll make sure your blog is fast, secure and always up so your visitors can engage with you. Plans start at $2.59/mo.

      OK, wait. How do you write a blog post? If you want to create value for readers and attract traffic to your site, it’s not as easy as typing up a few sentences in haste and clicking Publish. No, writing a great blog post requires creativity and smart crafting. And with the abundance of bloggers and the influx of ideas out there, you need to be at the top of your blogging game to cut through the noise and get eyes on your content.

      But don’t worry!

      We’re here to help. This everything-you-need guide covers it all: the reality behind blogging (aka vital stats to know), the ins-and-outs of crafting a great blog, and what handy resources are available to help with every aspect of writing your article.

      Dig in and study it word-for-word or just jump to the sections you need:

      Before we dive in too deep, let’s address something really fundamental: Why is writing a good blog post so important? Why does it even matter?

      So glad you asked (we love this topic)!

      Why Does Writing a Great Blog Post Matter?

      So what difference does a quality blog post make anyway?

      Well, the difference between a so-so blog post and a can’t-stop-reading blog post is a matter of only a handful of factors, but they’re crucial.

      An exceptional blog post not only helps attract your target audience to your site, but it helps establish you as an authority in your field and motivates visitors to continue engaging with you.

      In fact, 30% of people rank quality content as the top factor that adds credibility to a blog, so not only do you need to start a blog, you need excellent blog content. As you provide valuable content, readers will be more likely to develop loyalty to your brand. They’ll share your content with their friends, and trust us, social shares are the virtual word of mouth you need to flourish online.

      If you want authentic growth, you need killer blog posts.

      What Makes a Good Blog Post?

      So let’s break it down. What makes a perfect blog article? Here are the nine key ingredients.

      1. Targeted Message

      Or, in other words, Know Thy Audience. Ideally, you already know who you’re trying to reach with your brand or business.

      Similarly, your blog posts should be geared toward reaching and influencing a particular target audience — your specific niche — and addressing their needs. With a focused target, you are more likely to connect with audiences and build your brand. Casting an overly-wide net with your message will cause you to miss out on the key audiences that are most important for the growth of your brand.

      Valentine's Day post from House That Lars Built
      Brittany Jepsen of House That Lars Built knows her audience — creative DIY crafters — and tailors content for them.

      2. Clever Headline

      Your headline is often the make-it-or-break-it factor between someone clicking on your blog post or passing it by for some other site (likely a competitor’s content!)

      Your headline should grab readers, make them want more — tease and tantalize! — while still giving them a roadmap for the journey you’re going to take them on as well as an idea of what prize they’ll earn by adventuring. Invest the time to craft a good headline — it makes a big difference. Choose each word carefully.

      Pro-tip: Use a headline analyzer tool to get insight into the efficacy of your title and ways to improve.

      Behind-the-scenes blog post of Disneyland happenings.
      The author of this Disney Food Blog post entices readers with a behind-the-scenes look at Disneyland happenings.
      Blog post from At One Good Thing by Jillee.
      At One Good Thing by Jillee, this headline explains that the post will address a very common pain point — needing room-temperature ingredients in a pinch.
      Example of blog title using numbers.
      Using numbers is a solid way to quantify what value you’re offering to readers, like this post on author K.M. Weiland’s writing blog.

      3. Interesting Intro

      Kudos! You got a reader to click on your post, interested in finding more about your topic. Now — how to keep them reading (and keep your bounce rate steady)?

      You need a hook. You need to start your blog post with a captivating intro to draw the reader into your post. Whether you lead with a shocking stat, an engaging anecdote, a thought-provoking question, or an innovative idea, make your intro so compelling that your visitors can’t stop reading. Lure them in and hook ‘em.

      But take note — the introduction needs to satisfy the intent you hinted at in the headline or your audiences (and search engines) will punish you with lower traffic and rankings.

      Example of intriguing blog post intro.
      This post from Greatist hooks readers with an unexpected, intriguing intro.

      4. Valuable Content

      What does your blog post offer audiences? Readers are more likely to read and engage with your blog content if it offers them something of value, addresses a burning question, or solves a particularly deep pain point. Are you providing them with info they can’t find anywhere else? Is your content exclusive, comprehensive beyond your competitors, or outfitted with freebies or rich resources? Does it solve a problem?

      If so, then you’re on the right track.

      Let’s spend some time on this. Great blog posts are really all about understanding your audience — what they need, what they care about, how they behave. This type of research is crucial. Get to know them by reaching out to them, soliciting feedback, and asking questions. Get to know them and show you care.

      Next, do some internet research. Look at what people are searching for, what types of questions they’re asking (Google Auto-Complete anyone?). Browse Reddit, scout out competitor sites, and read comments.

      Simply put: Do your homework.

      Based on the intel you gather, develop a list of blog posts and content ideas that address the needs of your audience. You can start out with broad topics and then narrow the scope as you hone in on your niche. Plan what you need to distinguish your blog and beat out competitors in what you’re offering audiences.

      Popular content on the CSS-Tricks blog.
      The blog at CSS-Tricks clues readers into popular content and entices with the promise of answering a burning question.

      Need ideas on what kind of content to offer? Here are some well-received examples:

      • Listicles
      • Roundups
      • How-Tos/Tutorials
      • Exclusive Insights/Behind-the-Scenes

      5. Captivating Stories

      Visitors are more likely to connect with content that is relatable, human, and engaging, so gather your readers around the campfire (metaphorically, of course) and share relevant, captivating tales.

      Example of captivating story from Expert Vagabond blog.
      This post from Expert Vagabond hooks readers immediately with a captivating story.

      6. Easy-to-Scan Text

      Here’s an important stat for you. The average person spends only 37 seconds reading a blog post. If your text is long and clunky, it could be even less.

      Make your content easy to consume, organizing your snackable text in bite-sized pieces that’s easy to digest.

      Break up text into short paragraphs often, guided by informative subheads, emphasized text, and bullet points. Vary the length of your sentences, and utilize white space to provide visual breaks for readers’ eyes. Making text easier to read with consistent and organized formatting will help keep eyes on your content.

      7. Thoughtful Design

      It’s not just the content of your blog post that matters. Design (and blog structure) plays a big part in getting audiences to consume your content and engage with your brand. Pairing strong content with aesthetically-pleasing design makes your blog post that much more impactful.

      Thoughtful design includes smart use of white space, an attractive color scheme, easy-to-use navigation and menus, and other guiding design elements like leading lines and composition.

      It should also take into account the typical f-shaped scanning pattern when laying out design elements.

      Joi Knows How blog color scheme.
      The blog at Joi Knows How is united by a cohesive color scheme and engaging design elements, and thoughtful navigation.

      8. Authentic Writing

      The quickest way to turn off your audiences? Write content for them in an inauthentic voice. Visitors to your site don’t want salesperson speak, overly-technical jargon, academic mumbo-jumbo, or an unapproachable narrator — they want YOU. Your real, one-of-a-kind voice will keep them coming back for more.

      Example of relatable blog copy.
      Jessica of How Sweet Eats brings appeal to her blog posts not just by sharing delicious recipes and food photos — her writing feels real, relatable, and fun.

      9. Mobile-Responsiveness

      Mobile is king. Mobile internet usage has grown exponentially in the last few years, now dominating its share of traffic over desktop usage.

      Plus, more than five million people have smartphones, meaning that if audiences can’t access your blog post on mobile (or if your post isn’t responsive or attractive on their phone or tablet), they’re likely to hop to a competitor’s site.

      Prioritize a mobile-friendly blog to grow your brand. Use Google’s Mobile-Friendly Test to test out your site for possible responsiveness issues (this includes keeping things speedy!).

      Be Awesome on the Internet

      Join our monthly newsletter for tips and tricks to build your dream website!

      How to Write a Blog Post (In 6 Steps)

      Now, it’s time to write that blog post! Let’s get down to the nitty-gritty and do this step by step.

      1. Plan

      First, you need to sit down and prep your post. Planning is imperative to crafting a home-run blog post, especially if you want to stand out amongst your competitors and garner the attention you need.

      First off, you need to get yourself organized. Keep a running list of post ideas based on the research you’ve conducted on your audience and on valuable keywords. Brainstorm and mind map your thoughts. When planning your content calendar, consult your ideas and choose what would be the most useful for your target audience.

      Once you’ve settled on a winner, use a blog planner (like this one) and map out your topic. Create an outline with basic points and conduct the necessary research to flesh out important details. Visitors can get fake news anywhere on the web, so you owe it to your audience (and your brand) to only plan and create well-researched, high-value posts.

      And remember, it’s great to have a lot of content — more blog posts will draw more traffic. BUT. Make sure you’re prioritizing quality content over mere quantity and that you’re passionate about what you’re writing about.

      If you are, it will be evident — and contagious.

      2. Craft a Headline

      Your headline is crucial, remember? It’s got to be strong, or it’s not going to draw readers in.

      Remember: you want to entice and hint at what readers are going to get out of clicking on your article instead of someone else’s. A few headline pointers:

      • Optimal headline length is 11-14 words, both for social shares and search engine efficacy.
      • You need a captivating hook, plus enough info that your readers know what to expect and what value you’re offering them. Don’t just use throwaway clickbait phrases or pack in keywords. Trim the fat and use each word with intention.

      3. Write Your Post

      Time to start tickling those virtual ivories — meaning, it’s time to start writing your blog post. The average time spent writing a blog post has been increasing, so give yourself enough time (at least a few hours) to get your thoughts down and fully engage the writing process.

      The optimal length for blog posts is 2200-2500 words, so keep an eye on word count as you write. For now, don’t worry about making it perfect on the first go-around. Just keep those fingers moving and get the words down.

      Make sure to include a CTA (Call to Action) as you wrap up your post — you want your readers to be motivated to do something. And if they’ve stuck with you through a whole blog post, there’s a good chance they will.

      4. Find Images

      A blog post without images earns a big whomp, whomp, whomp — and gets little interest from readers and higher bounce rates. Blog articles with images get 94% more views.

      This means images — relevant, good quality ones — are absolutely necessary for your posts.

      DIY some of your own photography, get proper photo permissions for others’ work you want to share, or use a royalty-free site like Pexels or Unsplash to add images to your post and edit as necessary.

      You can also consider including alternative elements like infographics, charts, and graphics to create unique visual interest.

      Example of eye-catching image on Our Travel Passport blog.
      Eye-catching images are a hallmark of the Our Travel Passport blog, drawing readers in with visual interest.

      5. Edit Your Post

      Wait! Before clicking Publish, you need to edit your post. And no, a simple run of your standard-issue spell check isn’t enough.

      Here are some editing best practices:

      • Take a Break. Polish your post by stepping away from your keyboard for a time, then returning later with a fresh pair of eyes. The break will help you see errors you might have missed before.
      • Play Editor. Proofread your post with a fine-tooth comb and correct any grammar and spelling errors. Also take the opportunity to edit your text for clarity.
      • Think Syntax. The same type and length of sentences can get really boring — and difficult — to read. Vary your sentence length to keep things interesting.
      • Pack a Punch. Flimsy, weak-sounding copy turns off readers and leaves them unsatiated. Eliminate weak verbs and passive voice. You want your words to be strong and meaningful.
      • Get a Sounding Board. Read your text aloud to ensure it flows smoothly and sounds authentic and on-brand. Have a friend or colleague read over it and give feedback for an outsider’s perspective.
      • Fix Formatting. Make sure your text isn’t wonky when published. Preview it to ensure that it looks the way it’s supposed to — professional and well laid-out — providing plenty of visual space for eye breaks.

      Your blog content is a representation of your brand, so make sure it reflects a professional and polished image.

      6. Promote Your Post

      If you’ve followed the steps above, you’ve likely got a great blog post on your hands. That’s all fine and good, but if no one sees it, all your hard work is for naught! You’ll need to put in the content marketing legwork to get your post in front of your audience.

      Whether you use social media promotion, email marketing, paid advertising, or search engine optimization — ideally, a balance of all of these tactics — work to promote your post in ways that make sense for your target audiences.

      Helpful Blog Post Resources

      Don’t worry. We’re not done yet! We’ve got a handy-dandy toolbox of resources to help you make writing blog posts easy (and fun) — and above all, to help you build a successful blog and grow your brand. We know starting and maintaining a blog isn’t easy, but we’re here to help.

      Here are some super useful tools for each step of the writing process.

      Building a Website





      The Final Word on Starting a Blog

      Ready to craft some kick-butt blog posts? You’ve got everything you need to write great posts; now you need to team up with a great web host.

      We’ve got you covered.

      We’re experts at making things easy with top-tier tech support and resources for any SOS moments. Plus, we’re your biggest fans. Go you! Our Shared Hosting plans + your epic blogging skills = the perfect pair.

      Source link