How to use the insomnia-importers.convert function in insomnia-importers

To help you get started, we’ve selected a few insomnia-importers 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 Kong / insomnia / packages / insomnia-app / app / common / import.js View on Github external
export async function importRaw(
  getWorkspaceId: () => Promise,
  rawContent: string,
): Promise<{
  source: string,
  error: Error | null,
  summary: { [string]: Array },
}> {
  let results;
  try {
    results = await convert(rawContent);
  } catch (err) {
    return {
      source: 'not found',
      error: err,
      summary: {},
    };
  }

  const { data } = results;

  // Generate all the ids we may need
  const generatedIds: { [string]: string | Function } = {};
  for (const r of data.resources) {
    for (const key of r._id.match(REPLACE_ID_REGEX) || []) {
      generatedIds[key] = generateId(MODELS[r._type].prefix);
    }
github Kong / insomnia / packages / insomnia-app / app / ui / components / wrapper.js View on Github external
async _handleImport(text: string): Promise {
    // Allow user to paste any import file into the url. If it results in
    // only one item, it will overwrite the current request.
    try {
      const { data } = await importers.convert(text);
      const { resources } = data;
      const r = resources[0];

      if (r && r._type === 'request' && this.props.activeRequest) {
        // Only pull fields that we want to update
        return this._handleForceUpdateRequest(this.props.activeRequest, {
          url: r.url,
          method: r.method,
          headers: r.headers,
          body: r.body,
          authentication: r.authentication,
          parameters: r.parameters,
        });
      }
    } catch (e) {
      // Import failed, that's alright
github fbenz / restdocs-to-postman / src / curl-to-insomnia3.js View on Github external
const resourceWrappers = curlCommands.map(c => {
        return {
            path: c.path,
            resource: importers.convert(c.curl).data.resources[0]
        }
    });

insomnia-importers

Various data importers for Insomnia

Apache-2.0
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Popular insomnia-importers functions

Similar packages