How to use the snekfetch.post function in snekfetch

To help you get started, we’ve selected a few snekfetch 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 DS-Development / delet / commands / Information / tweet.js View on Github external
async fetchToken() {
    const { body } = await snekfetch
        .post("https://api.twitter.com/oauth2/token")
        .set({
            Authorization: `Basic ${base64(`${TWITTER_API_KEY}:${TWITTER_SECRET}`)}`,
            "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
        })
        .send("grant_type=client_credentials");

    this.token = body.access_token;
    return body;
  }
}
github DS-Development / delet / commands / Information / twitter.js View on Github external
async fetchToken() {
      const { body } = await snekfetch
        .post("https://api.twitter.com/oauth2/token")
        .set({
            Authorization: `Basic ${base64(`${TWITTER_API_KEY}:${TWITTER_SECRET}`)}`,
            "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
        })
        .send("grant_type=client_credentials");

      this.token = body.access_token;
      return body;
  }
}
github AdityaTD / PenguBot / functions / haste.js View on Github external
async run(input, extension = "js") {
        return post("https://hastebin.com/documents")
            .send(input)
            .then(res => `https://hastebin.com/${res.body.key}.${extension}`);
    }
github AdityaTD / PenguBot / commands / Utilities / poll.js View on Github external
async run(msg, [Question, ...Options]) {
        if (Options.length < 2) return msg.sendMessage("<:penguError:435712890884849664> ***Less than two options are not allowed.***");
        if (Options.length > 30) return msg.sendMessage("<:penguError:435712890884849664> ***I only allow 30 or less options.***");
        try {
            const { body } = await post("https://www.strawpoll.me/api/v2/polls")
                .send({ title: Question, options: Options })
                .catch(e => {
                    Error.captureStackTrace(e);
                    return e;
                });
            return msg.sendMessage(`<:penguSuccess:435712876506775553> ***Here's the poll you requested:*** https://www.strawpoll.me/${body.id}`);
        } catch (e) {
            return msg.sendMessage("<:penguError:435712890884849664> ***There was an error trying to create this poll, please try again.***");
        }
    }

snekfetch

Just do http requests without all that weird nastiness from other libs

MIT
Latest version published 6 years ago

Package Health Score

53 / 100
Full package analysis

Popular snekfetch functions

Similar packages