Thanks Sean~

http://posthere.io/ is really helped!

It turns out I have to using to transit with :json-verbose , or Spring (w/o 
transit) will failed to parse things like 

[ "^ ", "id", 8 ]

instead of 

{
  "id" : 2
}

On Saturday, July 4, 2015 at 6:31:13 PM UTC+8, Sean Johnson wrote:
> At the risk of promoting my own tool, I created a tool (in Clojure and 
> ClojureScript) to debug just this sort of problem. It's called: POSThere.io ( 
> https://github.com/SnootyMonkey/posthere.io )
> 
> Point your cURL command at POSTHere.io (you make up whatever URL you want, so 
> I just used the same one you were using, /todo/todos/delete):
> 
> curl -H "Content-Type: application/json" -X POST -d "{\"id\":1}" 
> http://posthere.io/todo/todos/delete
> 
> And update your CLJS code to use POSTHere.io:
> 
> (ajax/POST "http://posthere.io/todo/todos/delete";
>                {:format :json
>                 :response-format :json              
>                 :handler #(dispatch [:handle-del-resp %1])
>                 :error-handler #(dispatch [:handle-error %1])
>                 :params {"id" id}})
> 
> Then visit that POSThere.io URL: http://posthere.io/todo/todos/delete
> 
> It'll show all the details about your two posts and you can see exactly how 
> they differ.
> 
> Cheers,
> Sean
> 
> On Friday, July 3, 2015 at 8:16:39 AM UTC-4, Bin Li wrote:
> > I have spring contoler which talking json like :
> > 
> >     @RequestMapping(value = "/todos/delete", method = RequestMethod.POST)
> >     public String deleteTodo(@RequestBody Todo todo, Model model) {
> >             
> >             logger.info("/todos/delete : todo = " + todo);
> >             String status = "ok";
> >             int num = 0;
> >             try {
> >                     int id = todo.getId();
> >                     num = todoMapper.deleteByPrimaryKey(id);
> >             } catch (Exception e) {
> >                     logger.error("/todos/delete failed : " + e);
> >                     status = "fail";
> >             }
> > 
> >             // result
> >             model.addAttribute("out", "deleted " + num + " todo(s)");
> >             model.addAttribute("status", status);
> >             return jsonTemplate;
> >     }
> > 
> > With curl , I can post it like:
> > 
> > curl -H "Content-Type: application/json" -X POST -d "{\"id\":1}" 
> > http://localhost:8080/todo/todos/delete
> > 
> > Then I can get todo initialized.
> > 
> > But if I post with JulianBirch/cljs-ajax :
> > 
> >   (ajax/POST "/todo/todos/delete"
> >               {:format :json
> >                :response-format :json              
> >                :handler #(dispatch [:handle-del-resp %1])
> >                :error-handler #(dispatch [:handle-error %1])
> >                :params {"id" id}})
> > 
> > I am getting todo return null.
> > 
> > Any point will be appreciated, thanks in advanced!

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to