How to use the got.delete function in got

To help you get started, we’ve selected a few got examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electrode-io / electrode-native / ern-core / src / BundleStoreSdk.ts View on Github external
public async deleteStoreByAccessKey({ accessKey }: { accessKey: string }) {
    try {
      const storeId = await this.getStoreByAccessKey({ accessKey })
      await got.delete(`http://${this.host}/stores/${storeId}`, {
        ...this.gotCommonOpts,
        headers: {
          'ERN-BUNDLE-STORE-ACCESS-KEY': accessKey,
        },
      })
      return storeId
    } catch (err) {
      throw new Error(err.response?.text ?? err.message)
    }
  }
github electrode-io / electrode-native / ern-core / src / ErnBinaryStore.ts View on Github external
public async removeBinary(
    descriptor: AppVersionDescriptor,
    {
      flavor,
    }: {
      flavor?: string
    } = {}
  ): Promise {
    await this.throwIfNoBinaryExistForDescriptor(descriptor, { flavor })
    try {
      await got.delete(this.urlToBinary(descriptor, { flavor }), {
        ...this.gotCommonOpts,
      })
    } catch (err) {
      throw new Error(err.response?.text ?? err.message)
    }
  }
github parkroolucas / microservices-demo / api-gateway / src / adapters / UsersService.js View on Github external
static async deleteUserSession({ sessionId }) {
    const body = await got.delete(`${USERS_SERVICE_URI}/sessions/${sessionId}`).json();
    return body;
  }
github typicode / stop-server / bin.js View on Github external
function stop () {
  startup.remove('stop-server')
  got.delete('localhost:' + 5709)
}
github nasa / cumulus / packages / cmr-client / deleteConcept.js View on Github external
async function deleteConcept(type, identifier, provider, headers) {
  const url = `${getUrl('ingest', provider)}${type}/${identifier}`;
  log.info(`deleteConcept ${url}`);

  let result;
  try {
    result = await got.delete(url, {
      headers
    });
  } catch (error) {
    result = error.response;
  }
  const xmlObject = await parseXMLString(result.body);

  let errorMessage;
  if (result.statusCode !== 200) {
    errorMessage = `Failed to delete, statusCode: ${result.statusCode}, statusMessage: ${result.statusMessage}`;
    if (xmlObject.errors) {
      errorMessage = `${errorMessage}, CMR error message: ${JSON.stringify(xmlObject.errors.error)}`;
    }
    log.info(errorMessage);
  }
github babel / babel-bot / src / github.js View on Github external
const del = exports.del = (path: string) => {
    return got.delete(`${BASE_URI}${path}`, {
        headers
    });
};
github Cvmcosta / ltijs / dist / Provider / Services / Grade.js View on Github external
query: query,
        headers: {
          Authorization: tokenRes.token_type + ' ' + tokenRes.access_token
        },
        body: JSON.stringify({
          request: 'lineitems'
        })
      });
      lineitemRes = JSON.parse(lineitemRes.body);
      let success = true;

      for (const lineitem of lineitemRes) {
        try {
          const lineitemUrl = lineitem.id;
          provGradeServiceDebug('Deleting: ' + lineitemUrl);
          await got.delete(lineitemUrl, {
            headers: {
              Authorization: tokenRes.token_type + ' ' + tokenRes.access_token
            },
            body: JSON.stringify({
              request: 'lineitems'
            })
          });
          provGradeServiceDebug('LineItem sucessfully deleted');
        } catch (err) {
          provGradeServiceDebug(err.message);
          if ((0, _classPrivateFieldGet2.default)(this, _logger)) (0, _classPrivateFieldGet2.default)(this, _logger).log({
            level: 'error',
            message: 'Message: ' + err.message + '\nStack: ' + err.stack
          });
          success = false;
          continue;
github Cvmcosta / ltijs / src / Provider / Services / Grade.js View on Github external
if (filters.resourceLinkId) queryParams.push(['resource_link_id', idtoken.platformContext.resource.id])
        if (filters.limit) queryParams.push(['limit', filters.limit])
        if (filters.tag) queryParams.push(['tag', filters.tag])
        if (filters.resourceId) queryParams.push(['resource_id', filters.resourceId])
        query = new URLSearchParams(queryParams)
      }

      let lineitemRes = await got.get(lineitemsEndpoint, { query: query, headers: { Authorization: tokenRes.token_type + ' ' + tokenRes.access_token }, body: JSON.stringify({ request: 'lineitems' }) })
      lineitemRes = JSON.parse(lineitemRes.body)
      let success = true
      for (const lineitem of lineitemRes) {
        try {
          const lineitemUrl = lineitem.id

          provGradeServiceDebug('Deleting: ' + lineitemUrl)
          await got.delete(lineitemUrl, { headers: { Authorization: tokenRes.token_type + ' ' + tokenRes.access_token }, body: JSON.stringify({ request: 'lineitems' }) })
          provGradeServiceDebug('LineItem sucessfully deleted')
        } catch (err) {
          provGradeServiceDebug(err.message)
          if (this.#logger) this.#logger.log({ level: 'error', message: 'Message: ' + err.message + '\nStack: ' + err.stack })
          success = false
          continue
        }
      }
      return success
    } catch (err) {
      provGradeServiceDebug(err.message)
      if (this.#logger) this.#logger.log({ level: 'error', message: 'Message: ' + err.message + '\nStack: ' + err.stack })
      return false
    }
  }
github alex-phillips / node-clouddrive / lib / Node.js View on Github external
unlink(idParent, callback) {
    let retval = {
      success: false,
      data: {},
    };

    Logger.verbose('Requesting nodes:children:delete endpoint (unlink)');
    Logger.debug(`HTTP Request: DELETE '${account.metadataUrl}nodes/${idParent}/children/${this.getId()}'`);
    got.delete(`${account.metadataUrl}nodes/${idParent}/children/${this.getId()}`, {
      headers: {
        Authorization: `Bearer ${account.token.access_token}`,
      },
    })
      .then(response => {
        Logger.debug(`Response returned with status code ${response.statusCode}.`);
        Logger.silly(`Response body: ${response.body}`);
        retval.data = JSON.parse(response.body);

        if (response.statusCode === 200) {
          retval.success = true;
          this.replace(retval.data);

          return this.save(() => {
            return callback(null, retval);
          });