Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createRequest(data, payload) {
if (typeof data === 'string') {
data = {url: data};
}
if (payload) {
if (typeof payload === 'string') {
payload = ArrayBuffer.fromString(payload);
}
data.payload = payload;
if (!data.method) data.method = Method.POST;
}
const request = require.weak('coap/create_request')(data);
if (!request.messageId) request.messageId = this._issueMessageId();
if (!request.token) request.token = this._issueToken();
return request;
}
post(url, payload, callback) {
return this.send({url, method:Method.POST}, payload, callback);
}