olofd / react-native-signalr

Use SignalR with React Native
150 stars 61 forks source link

Question: Using Query String #22

Closed oatcrunch closed 7 years ago

oatcrunch commented 7 years ago

Hi,

Just a simple query, how do I include query string using this library? The example in C# would be as follows:

var qs = "username=rendang"; var url = "http://192.168.93.139/SignalRHub/"; hubConnection = new HubConnection(url, qs);

Do we have the equivalent way of doing this? I tried using the traditional way using this library, but doesn't seem to work ie:

let qs = "username=rendang"; let url = "http://192.168.93.139/SignalRHub"; let fullUrl = url + "?" + qs; const connection = signalr.hubConnection(fullUrl);

And this way as well:

let qs = "username=rendang"; let url = "http://192.168.93.139/SignalRHub";

    let fullUrl = url;
    const connection = signalr.hubConnection(fullUrl, qs);

Appreciate some advice.

Note: Sorry, I am very new to JS and ES6 language.

oatcrunch commented 7 years ago

Hi, is there any kind soul with the knowledge to help on the above query? If the this feature exists kindly provide some guidance on how can it be done; or any workaround will also be fine.

Thanks in advance.

olofd commented 7 years ago

@oatcrunch I think you do it this way, by sending it in the options-object.

const connection = signalr.hubConnection(fullUrlWithoutQueryString, {
 qs : "username=rendang"
});

Let me know if it does not work!

oatcrunch commented 7 years ago

Hi @olofd . I have tested your suggested method. It works :) Thanks for your help.

olofd commented 7 years ago

@oatcrunch Great! Then I'm closing this issue.