0

I have a Scalatra web application, when a user sends a get request to the server, ie. www.example.com/getsomething it routes to the following code:

class ExampleServlet extends ScalatraServlet {
   get("/getsomething") { 
    //code here
   }
}

In the body of the get I would like to send out another get request to another server and capture the JSON that is sent back eg:

var JSONback = GetRequest("www.SomeOtherApi.com/getsomeJSON")

How would I achieve something like this?

Thanks

1 Answer 1

2

For basic needs you could use scala.io.Source

scala.io.Source.fromURL("http://www.google.de","latin1").mkString
res10: String =
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage"     ="de"><head><meta content="text/html; charset=UTF-8"

For more sophisticated use cases you can use any http-client-library like:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.