Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code sample not up to date #15

Open
klehmann opened this issue Jun 13, 2019 · 0 comments
Open

Code sample not up to date #15

klehmann opened this issue Jun 13, 2019 · 0 comments

Comments

@klehmann
Copy link

klehmann commented Jun 13, 2019

I just tried to run the code sample (on iOS) and found out that the first parameter for the respond method call is not correct.

The sample should look like this:

componentWillMount() {
      // initalize the server (now accessible via localhost:1234)
      httpBridge.start(5561, "bonjourName", function(request) {

          // you can use request.url, request.type and request.postData here
          if (request.type === "GET" && request.url.split("/")[1] === "users") {
            httpBridge.respond(request.requestId, 200, "application/json", "{\"message\": \"OK\"}");
          } else {
            httpBridge.respond(request.requestId, 400, "application/json", "{\"message\": \"Bad Request\"}");
          }

      });
    }

request.requestId is missing in your code.

Edit:
Just saw that pull request #10 contains the same correction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant