olofd / react-native-signalr

Use SignalR with React Native
150 stars 61 forks source link

addQs method can't find this method from jquery '$.param' #7

Closed lucio-c closed 8 years ago

olofd commented 8 years ago

@cuixiaolu Please give some more information regarding this. Preferably submit a PR.

jonoirwinrsa commented 8 years ago

This error occurs when trying to add headers as an object to the connection query string eg: connection.qs = { 'Bearer' : token }; connection.start()...

If you send the headers as a serialised string it works alright

olofd commented 8 years ago

Sry for late response. Do you guys have any idea how to fix this? I can take a look this coming week, but I would want a bit more code that will reproduce the issue.

jonoirwinrsa commented 8 years ago

In my case I ended up not needing the query strings so I'm afraid I don't have a fix..

olofd commented 8 years ago

Ah. Ok. Then, if it's okay with you I'll close this for now. If more people report or have this issue we can open it again.

thomasvm commented 7 years ago

I've encountered the same scenario, needed the .qs for authentication to work on signalr hubs. Ended up adding the following code to my own project in order to polyfill jQuery.param. This only supports very basic objects no nested objects

jQuery.param = (obj) => {
  const str = [];
  for (const p in obj) {
    if (obj.hasOwnProperty(p)) {
      str.push(
        `${encodeURIComponent(p)}=${encodeURIComponent(obj[p])}`
      );
    }
  }
  return str.join('&');
};