fergiemcdowall / norch

A search server that can be installed with npm
655 stars 45 forks source link

How to format data before use /add ? #151

Closed wayearn closed 7 years ago

wayearn commented 7 years ago

We need to format data and use the engine before the data add.

Is there anyway to do it?

fergiemcdowall commented 7 years ago

You mean to get the data into JSON? Or to change the structure of existing JSON? Or something else?

Could you be more specific?

wayearn commented 7 years ago

No, I have a JSON data need to format when use your /add api, like a Middleware:

norch().then({here's format data Middleware}).call('add',function(){})

I build a simple app use request, but I got proxy error:

    request.post({
      url: "http://localhost:3030/add",
      method: "POST",
      // json: true,   
      body: JSON.stringify(data),
      headers:{
        'Content-Type': 'application/json'
      }
    },function (error, response, body) {
      console.log('error:', error); // Print the error if one occurred
      console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
      console.log('body:', body); // Print the HTML for the Google homepage.
    });

My app runs at localhost:3000, and norch runs at localhost:3030, got proxy error. But, when I use another host not localhost, like 127.0.0.2 to run norch, and my app runs at 127.0.0.1, my app works.

fergiemcdowall commented 7 years ago

Hmmm- that sounds like you are experiencing network problems, but Norch is working?

wayearn commented 7 years ago

Norch is working!