Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

MJS callback error: [HTTP] is not defined

aravindmj97aravindmj97 INDIA
edited May 2018 in Mongoose OS

I'm trying to do a http cloud function call from my NodeMCU, but im getting the error as in the title MJS callback error: [HTTP] is not defined. I'm coding NodeMCU using JavaScript. Couldn't find a solution for this. Please provide me with a solution.
This is my code

HTTP.query({
    url: 'https://.....',
    headers: { 'X-Foo': 'bar' },     // Optional - headers
    data: {foo: 1, bar: 'baz'},      // Optional. If set, JSON-encoded and POST-ed
    success: function(body, full_http_msg) { print(body); },
    error: function(err) { print(err); },  // Optional
  });

Comments

  • nliviunliviu Romania

    HTTP is defined in api_http.js
    You need to load('api_http.js'); in init.js.

    api_http.js is pulled in by the mjs library. Make sure it is listed in yours mos.yml libs section.

    Documents to read:
    mjs
    Starting with JavaScript
    Advanced JavaScript
    mongoose-os-libs
    mongoose-os-apps

  • On adding the api_http the error is gone. But when the code of HTTP.request is executed the Mongoose Environment gets stuck and it has to be restarted. The URL doesn't return any thing. It's for writing data to firebase. The URL with arguments is passed for writing in the firebase.

  • nliviunliviu Romania
    edited May 2018

    I don't use firebase.
    Check the connection to firebase settings.

    LE. Did you really use the HTTP.query parameters from the example in api_http.js? If yes, it will not work for what you are trying to do.

  • nliviunliviu Romania

    The mongoose library is provided only in binary form and ssl support is not enabled. Thus, https is not supported.

Sign In or Register to comment.