Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
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);
});
});
}
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);
});
});
});
});
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) {
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();
});
});
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);
});
});
});
return new Bluebird(function (resolve, reject) {
Wreck.post(uri, options, function (err, res, payload) {
if (err) return reject(err)
return resolve([
res,
payload,
])
})
})
}
.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 => {
_send(messagePayload, callback) {
const payload = Hoek.applyToDefaults(this._config.slack, messagePayload);
const data = {
payload: Stringify(payload)
};
Wreck.post(this._config.url, data, callback);
}
}