Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:22:42+00:00 2026-06-05T18:22:42+00:00

I am working on re-writing an existing web site using Node.js with Express. Front-end

  • 0

I am working on re-writing an existing web site using Node.js with Express.

Front-end of the site will use Backbone JS and thus I need to have all necessary routes comply with native Backbone sync. Now most of URL’s the client and for Backbone sync will be same. But they won’t work for regular GET as they would need to return JSON.

So I am thinking, would it be a good idea to add extension to Model/Collection URLs in Backbone, such as .json, and in Express to have this for every route:

app.get('/p/:topCategory/:category/:product.:format', function(req, res) { ... });

Where if (req.params.id == 'json') than we send JSON, otherwise we render HTML?

Or is there a better approach? Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:22:43+00:00Added an answer on June 5, 2026 at 6:22 pm

    The better way of doing this would be to use the content negotiation feature in Express 3.x, namely res.format:

    https://github.com/visionmedia/express/blob/master/lib/response.js#L299-378

    res.format({
      text: function(){
        res.send('hey');
      },
    
      html: function(){
        res.send('<p>hey</p>');
      },
    
      json: function(){
        res.send({ message: 'hey' });
      }
    });
    

    You approach is also ok, Yammer for ex. is using the same approach: http://developer.yammer.com/api/#message-viewing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on writing a small WSGI application using Bottle and SqlAlchemy and am
I'm working on writing a small application using the WPF MediaKit , and I
I'm working on writing a FileSystemWatcher using Mono but for some reason the callback
I'm working on a web crawler (please don't suggest an existing one, it's not
I'm writing some scripts for my Git workflow. I need to reset other (existing)
I am re-engineering a site from an existing site, and I am writing acceptance
I am working on a tool which audits access to existing web application. Existing
I need ideas for a problem I am working on: I am writing a
I'm currently working on a legacy eCommerce system front-end that has alot of duplicate
I was working on writing some servlets and they all worked fine Tomcat had

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.