How to use prepend-http - 8 common examples

To help you get started, we’ve selected a few prepend-http 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 khaosdoctor / gotql / src / modules / runner.ts View on Github external
export async function run (endPoint: string, query: QueryType, type: GotQL.ExecutionType, got: GotInstance, options?: UserOptions): Promise {
  try {
    info('Invoking runner with query type %s', type)
    if (!['query', 'mutation'].includes(type)) throw new Error('Query type must be either `query` or `mutation`')

    info('Parsing query: %O', query)
    const graphQuery = parse(query, type) // Parses JSON into GraphQL Query
    info('Parsed query: %s', graphQuery)

    info('Building payload object')
    const headers = options ? options.headers : {}
    const gotPayload = getPayload(headers, query, graphQuery)
    info('Payload object: %O', gotPayload.body)
    info('Sending request...')
    let response = await got.post(prependHttp(endPoint), gotPayload)
    info('Response: %O', response.body.toString())

    return handleResponse(response, options)
  } catch (error) {
    shout('Error on runner: %O', error)
    throw new RunnerError(`Error when executing query: ${error.message}`)
  }
}
github microlinkhq / www / src / components / pages / meta / examples.js View on Github external
onSubmit={event => {
            event.preventDefault()
            const url = prependHttp(inputValue)
            onSubmit(isUrl(url) ? url : undefined)
          }}
        >
github opencollective / opencollective-api / server / controllers / collectives.js View on Github external
avatar = `${config.host.website}${avatar}`
      }
      const u = {
        ...userCollective.dataValues,
        tier: userCollective.tier && userCollective.tier.slug,
        avatar
      };
      delete u.image;
      if (!u.tier) {
        u.tier = (u.type === 'USER') ? 'backer' : 'sponsor';
      }
      if (!req.collective || !req.remoteUser || !req.remoteUser.isAdmin(req.collective.id)) {
        delete u.email;
      }
      if (u.website) {
        u.website = prependHttp(u.website);
      }
      return u;
    })
    .then(users => res.send(users))
github opencollective / opencollective-api / server / models / Collective.js View on Github external
get() {
          const website = this.getDataValue('website');
          if (website) {
            return prependHttp(website);
          }
          return this.getDataValue('twitterHandle')
            ? `https://twitter.com/${this.getDataValue('twitterHandle')}`
            : null;
        },
        set(url) {
github microlinkhq / www / src / components / pages / meta / examples.js View on Github external
useEffect(() => {
    if (isLoading) return
    const value = prependHttp(inputValue)
    if (!isUrl(value)) return setData(demoLink.data)
    const item = suggestions.find(({ value }) => value === inputValue)
    if (item) setData(item.data)
    else fetchAndSetData(value)
  }, [inputValue])

  const media =
    previewView === 'iframe'
      ? ['iframe', 'video', 'audio', 'image', 'logo']
      : ['video', 'audio', 'image', 'logo']

  const targetUrlPrepend = prependHttp(demoLink.data.url)

  return (
    <>
      
        

         {
            event.preventDefault()
github opencollective / opencollective-api / server / controllers / collectives.js View on Github external
avatar = `${config.host.website}${avatar}`;
      }
      const u = {
        ...userCollective.dataValues,
        tier: userCollective.tier && userCollective.tier.slug,
        avatar,
      };
      delete u.image;
      if (!u.tier) {
        u.tier = u.type === 'USER' ? 'backer' : 'sponsor';
      }
      if (!req.collective || !req.remoteUser || !req.remoteUser.isAdmin(req.collective.id)) {
        delete u.email;
      }
      if (u.website) {
        u.website = prependHttp(u.website);
      }
      return u;
    })
    .then(users => res.send(users))

prepend-http

Prepend `https://` to humanized URLs like sindresorhus.com and localhost

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular prepend-http functions