MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / _requestCreate

Method _requestCreate

lib/helper/ApiDataFactory.js:366–388  ·  view source on GitHub ↗

* Executes request to create a record in API. * Can be replaced from a in custom helper. * * @param {*} factory * @param {*} data

(factory, data)

Source from the content-addressed store, hash-verified

364 * @param {*} data
365 */
366 _requestCreate(factory, data) {
367 let request = createRequestFromFunction(this.factories[factory].create, data)
368
369 if (!request) {
370 const method = Object.keys(this.factories[factory].create)[0]
371 const url = this.factories[factory].create[method]
372 request = {
373 method,
374 url,
375 data,
376 }
377 }
378
379 request.baseURL = this.config.endpoint
380
381 return this.restHelper._executeRequest(request).then(resp => {
382 const id = this._fetchId(resp.data, factory)
383 this.created[factory].push(id)
384 this.debugSection('Created', `Id: ${id}`)
385 if (this.config.returnId) return id
386 return resp.data
387 })
388 }
389
390 /**
391 * Executes request to delete a record in API

Callers 1

haveMethod · 0.95

Calls 4

_fetchIdMethod · 0.95
_executeRequestMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected