0

We're trying to test an Alomofire GET request using a Playground. It's working but we can't see the JSON returned by the request in the Playground. How can you do this? Note clicking the right arrows in the screen shot doesn't show any JSON.

Playground:

enter image description here

The request's JSON response:

{ "userId": 1, "id": 2, "title": "qui est esse", "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla" } 
2

1 Answer 1

1

Your playground ended before the request could complete. Pause it indefinitely by setting needsIndefiniteExecution = true:

import UIKit import SwiftyJSON import Alamofire import XCPlayground Alamofire.request(.GET, "http://jsonplaceholder.typicode.com/posts/2") .responseJSON { response in let json = JSON(data: response.data!) print(json) } XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I believe this API has changed per stackoverflow.com/a/33536290/4096655 - which worked. Thanks for the help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.