How to use the coap/common.Method.POST function in coap

To help you get started, we’ve selected a few coap 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 Kinoma / kinomajs / xs6 / sources / mc / extensions / coap / client.js View on Github external
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;
	}
github Kinoma / kinomajs / xs6 / sources / mc / extensions / coap / client.js View on Github external
post(url, payload, callback) {
		return this.send({url, method:Method.POST}, payload, callback);
	}