How to use the putOrPost function from request

Find comprehensive JavaScript request.putOrPost code examples handpicked from public code repositorys.

105
106
107
108
109
110
111
112
113
114
115
        data[widget.name] = widget.value;
      }
    }
  });


  Request.putOrPost("/scenarios",
                    scenario.id,
                    { scenario: data },
                    resp => m.route.set("/scenarios/" + resp.data.id));
};
fork icon1
star icon1
watch icon0

+ 3 other calls in file

298
299
300
301
302
303
304
305
306
307
308
              });
};


//========================================================================
const submitResourceForm = () => {
  Request.putOrPost("/scenarios/" + scenario().id + "/resource",
                    resourceId(),
                    {
                      resource: {
                        id:            resourceId() ? resourceId() : null,
fork icon1
star icon1
watch icon0

346
347
348
349
350
351
352
353
354
355
if (!character.name) {
  Request.errors("Name is required");
  return;
}

Request.putOrPost(
  "/character",
  character.id,
  { character: character },
  () => {
fork icon1
star icon1
watch icon0

25
26
27
28
29
30
31
32
33
34
if (!figure.name) {
  Request.errors("Name is required!");
  return;
}

Request.putOrPost("/figure",
                  figure.id,
                  { figure: figure },
                  () => {
                    Request.messages("Saved " + figure.name);
fork icon1
star icon1
watch icon0