How to use the wreck.post function in wreck

To help you get started, we’ve selected a few wreck 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 mtharrison / hapi.js-in-action / test / CH02.js View on Github external
serves: 16,
                    cuisine: 'Mongolian',
                    ingredients: 'Cheese',
                    directions: 'Melt'
                };

                const options = {
                    payload: JSON.stringify(recipe),
                    headers: {
                        'content-type': 'application/json'
                    }
                };

                // No-authentication

                Wreck.post('http://localhost:4000/api/recipes', options, (err, res, payload) => {

                    expect(err).to.not.exist();
                    expect(res.statusCode).to.equal(401);

                    // With authentication

                    options.headers.Authorization = 'Bearer q8lrh5rzkrzdi4un8kfza5y3k1nn184x';

                    Wreck.post('http://localhost:4000/api/recipes', options, (err, res, payload) => {

                        expect(err).to.not.exist();
                        expect(res.statusCode).to.equal(200);

                        Wreck.get('http://localhost:4000/api/recipes?cuisine=Mongolian', (err, res, payload) => {

                            expect(err).to.not.exist();
github fishin / ficion / queue.js View on Github external
Wreck.get(url + '/job/byname/' + projects[i], { json: true }, function(err1, resp1, payload1) {

            var jobId = payload1.id;
            var payload = { jobId: jobId };
            var options = {
                payload: JSON.stringify(payload),
                json: true
            };
//            console.log(options);
            Wreck.post(url + '/queue', options, function(err2, resp2, payload2) {
                if (payload2 && payload2.statusCode) {
                    console.log(payload2);
                };
                iterate(i + 1);
            });
        });
    }
github mtharrison / hapi.js-in-action / test / CH03.js View on Github external
const options = {
                            headers: {
                                cookie: res.headers['set-cookie'][0].split(';')[0]
                            },
                            payload: JSON.stringify({
                                name: 'Web test',
                                cooking_time: '12 mins',
                                prep_time: '15 mins',
                                serves: 16,
                                cuisine: 'Mongolian',
                                ingredients: 'Cheese',
                                directions: 'Melt'
                            })
                        };

                        Wreck.post('http://localhost:4000/create', options, (err, res, payload) => {

                            expect(err).to.not.exist();
                            expect(res.statusCode).to.equal(302);
                            expect(res.headers.location).to.equal('http://localhost:4000');

                            Wreck.get('http://localhost:4000/', options, (err, res, payload) => {

                                expect(err).to.not.exist();
                                expect(res.statusCode).to.equal(200);
                                expect(payload.toString()).to.include('Web test');
                                cleanup(child, done);
                            });
                        });
                    });
                });
github mtharrison / hapi.js-in-action / test / CH09.js View on Github external
throw err;
                    }

                    let cookie = res.headers['set-cookie'][0].split(';')[0];
                    expect(payload.toString()).to.include('Feeling great!');

                    let options = {
                        headers: {
                            cookie: cookie
                        },
                        payload: JSON.stringify({
                            message: 'Something else'
                        })
                    };

                    Wreck.post('http://localhost:4000/change', options, (err, res, payload) => {

                        if (err) {
                            throw err;
                        }

                        cookie = res.headers['set-cookie'][0].split(';')[0];

                        options = {
                            headers: {
                                cookie: cookie
                            }
                        };

                        Wreck.get('http://localhost:4000/', options, (err, res, payload) => {

                            if (err) {
github hapijs / hapi / test / gzip.js View on Github external
it('returns a gzip response on a post request when accept-encoding: gzip is requested', function (done) {

        Wreck.post(uri, { headers: { 'accept-encoding': 'gzip' }, payload: data }, function (err, res, body) {

            expect(err).to.not.exist;
            expect(body).to.equal(zdata);
            done();
        });
    });
github mtharrison / hapi.js-in-action / test / CH04.js View on Github external
Wreck.get('http://localhost:4000/', (err, res, payload) => {

                    expect(err).to.not.exist();
                    expect(payload.toString()).to.equal('Route was matched for a get request');

                    Wreck.post('http://localhost:4000/', (err, res, payload) => {

                        expect(err).to.not.exist();
                        expect(payload.toString()).to.equal('Route was matched for a post request');
                        cleanup(child, done);
                    });
                });
            });
github christophercliff / flatmarket / packages / flatmarket-hapi / __test__ / index.spec.js View on Github external
return new Bluebird(function (resolve, reject) {
        Wreck.post(uri, options, function (err, res, payload) {
            if (err) return reject(err)
            return resolve([
                res,
                payload,
            ])
        })
    })
}
github synapsestudios / oidc-platform / api / src / application / webhook / getQueue.js View on Github external
.then(jwt => {
        const options = {
          payload: data.payload,
          timeout: webhookConfig.timeout,
          headers: {
            Authorization: 'Bearer ' + jwt,
          }
        };

        Wreck.post(data.url, options, (err, response, payload) => {
          cb(err, response);
        });
      })
      .catch(err => {
github nakardo / good-slack / lib / index.js View on Github external
_send(messagePayload, callback) {

        const payload = Hoek.applyToDefaults(this._config.slack, messagePayload);

        const data = {
            payload: Stringify(payload)
        };

        Wreck.post(this._config.url, data, callback);
    }
}

wreck

HTTP Client Utilities

BSD-3-Clause
Latest version published 6 years ago

Package Health Score

56 / 100
Full package analysis

Popular wreck functions