# superMap, get server response

**URL:** <https://forums.bitovi.com/t/supermap-get-server-response/462>\
**Category:** CanJS\
**Created:** [November 9, 2016, 3:19pm UTC](https://forums.bitovi.com/t/supermap-get-server-response/462 "2016-11-09T15:19:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fp\_dev](https://avatars.discourse-cdn.com/v4/letter/f/13edae/32.png) [@fp\_dev](https://forums.bitovi.com/u/fp_dev)\
**Post date:** [November 9, 2016, 3:19pm UTC](https://forums.bitovi.com/t/supermap-get-server-response/462/1 "2016-11-09T15:19:17Z")

</div>

Can someone suggest me a way (if any) to intercept the server response when requesting a CRUD action using **can-connect/can/super-map/super-map**?

For instance, after executing calling the **save()** method on the superMap object, if the server replies with an existing **id** entry (id as idProp), the instance properties will be updated (otherwise created). But if i want to handle errors caming from the server, sending back a special message, is it possible to get it before the **updateData()** is executed?

Thank you.

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [November 9, 2016, 3:34pm UTC](https://forums.bitovi.com/t/supermap-get-server-response/462/2 "2016-11-09T15:34:28Z")

</div>

Configuring `superMap` in that way isn’t really possible. But if you build your own connection, all things are possible.

What do you mean by special message? Do you mean set a special property?

To build your own connection, I usually copy `superMap`'s code: [https://github.com/canjs/can-connect/blob/master/can/super-map/super-map.js](https://github.com/canjs/can-connect/blob/master/can/super-map/super-map.js)

And then add my own behavior to the end:

```auto
behaviors.push(function(base){
  return {
    updateData: function(){
      
    }
  }
})

```

It sounds to me like you more want to overwrite `createdInstance` or `updatedInstance`: [http://v3.canjs.com/doc/can-connect/constructor/constructor.createdInstance.html](http://v3.canjs.com/doc/can-connect/constructor/constructor.createdInstance.html)

---

<div class="post-metadata">

**Author:** ![fp\_dev](https://avatars.discourse-cdn.com/v4/letter/f/13edae/32.png) [@fp\_dev](https://forums.bitovi.com/u/fp_dev)\
**Post date:** [November 9, 2016, 3:54pm UTC](https://forums.bitovi.com/t/supermap-get-server-response/462/3 "2016-11-09T15:54:54Z")

</div>

Thank for your suggestion, justin!  
I will try that way.

For special message I mean, for instance, an error code and description, to be sent back from the server in case of failure of the update operation.

```
PUT /my/resource/1
with data { fied1: "a", field2:"b"}

the server will reply
{field1:"a", field2:"b"} // if success
{error:"unable to save due to blabla...", code:123} // if error occurs

```

The save problem I have when connection to the server fails ( ajax goes to error): it is possible to catch this event?

Thank you a lot.

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [November 17, 2016, 11:27pm UTC](https://forums.bitovi.com/t/supermap-get-server-response/462/4 "2016-11-17T23:27:14Z")

</div>

by catch the event do you mean:

```auto
modelInstance.save().catch(function(error){

})

```

Then yes … that is exactly how you do it.
