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 8932475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:19:28+00:00 2026-06-15T09:19:28+00:00

How can I append ?apiKey=12341234 onto every ajax request for fetch, create, save etc…

  • 0

How can I append ?apiKey=12341234 onto every ajax request for fetch, create, save etc… The MongoLabs api requires this and i’ve been struggling to get this to work fully.

I’m currently working though a backbone tutorial screencast and the author is using a php framework to create an api for the backbone app. I thought I was going to be smart by using MongoLabs free rest api… and then I burnt up 2 days reading docs and trying to make it work.

The closest i’ve come is to pass in the param when fetch is called (doesn’t work with create): Fetch Backbone collection with search parameters

{ data: $.param({'apiKey':'50b28f80e4b0995a3f4312a0'}) }

Working url:
https://api.mongolab.com/api/1/databases/bbone_rest/collections/tasks/2/?q=&apiKey=50b28f80e4b0995a3f4312a0

Code on jsfiddle:
http://jsfiddle.net/py4Pv/

# Encapsulate classes
window.App =
  apiKey: { data: $.param({'apiKey':'50b28f80e4b0995a3f4312a0'}) }
  Models: {}
  Views: {}
  Collections: {}



# The model for a single task
class App.Models.Task extends Backbone.Model
  #override backbones 'id' attr to match mongo's '_id' attr
  idAttribute: "_id"
  defaults:
    title: "None provided"
    completed: 0


# The model for a collection of tasks
class App.Collections.Tasks extends Backbone.Collection
  model: App.Models.Task
  url: 'https://api.mongolab.com/api/1/databases/bbone_rest/collections/tasks/'





##################### Views, prob not important ########################  


# View for a list of tasks
class App.Views.Tasks extends Backbone.View
  tagName: 'ul'

  initialize : () ->
    @collection.on 'add', @addOne

  render: ->
    # Cycle through each task in collection and call @addOne
    @collection.each @addOne
    return this

  addOne: (task) =>
    task = new App.Views.Task({ model: task })
    @$el.append( task.render().el )


# View for a single task unit
class App.Views.Task extends Backbone.View
  tagName: 'li'
  render: ->
    @$el.html( this.model.get('title'))
    return this

* Edit *
Headers info when adding : $.ajaxSetup({ data: { key: “value”} after a task.destroy()

Request URL:https://api.mongolab.com/api/1/databases/bbone_rest/collections/tasks/1
Request Method:OPTIONS
Status Code:400 Bad Request

Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:origin, accept
Access-Control-Request-Method:DELETE
Connection:keep-alive
Host:api.mongolab.com
Origin:null
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11

Response Headersview source
Connection:close
Content-Length:50
Content-Type:application/json;charset=utf-8
Date:Fri, 30 Nov 2012 06:42:57 GMT
Server:Apache/2.2.22 (Ubuntu)
  • 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-15T09:19:29+00:00Added an answer on June 15, 2026 at 9:19 am

    You can specify a function for the url property of the model/collection — that way you should be able to append the api in the query string each time. Ie, something like (sorry, I’m unsure of Mootools syntax):

    url: () => 
       return 'https://api.mongolab.com/api/1/databases/bbone_rest/collections/tasks/' + this._id + '?api=' + App.apiKey
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a command that can append one array of char onto another? Something
How can I append this <% =i %> variable onto this. <asp:DropDownList ID=AdTitle runat=server>
I can fetch the item names from a database and append them to an
How can I return the value pinNumber from jquery ajax so I can append
I know you can append limit and offset values to the graph.facebook.com/id/photos API call
If I have some R list mylist , you can append an item obj
How can i append 2nd page of a pdf file to the first page.
in F#, array.append can join two arrays; is there a way to append 2
Can extensive StringBuilder.Append() operations be optimized by using char[] allocated on thread's stack to
I would like some container that I can very efficiently append a variable amount

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.