Giter Site home page Giter Site logo

fetch-api-nashorn's Introduction

Fetch-API-Nashorn

Java JavaScript
Implement Fetch API in Nashorn!
With this Complete you will be able to Run fetch in Java with Nashorn!

Credits to the bookstore of:

nashorn-polyfill

How to install:

First you have to run the JavaScript file with Nashorn from Java lib/GlobalAPI.js and Creadores Program/Fetch API.js and then upload your code and you are ready to use the Fetch API!

How to use:

The API is Slightly different than the Browser but it does the same here an explanation:

//How to make a GET request
var requestGET = fetch("https://theurltest.com", "GET");
console.info("The page say: " + requestGET);
//It also works without putting "GET" example:
var requestGET2 = fetch("https://theurltest.com");
console.info("The page say: " + requestGET2);
//How to make POST request
var requestPOST = fetch("https://theurltest.com", "POST", JSON.stringify({
    content: "Content you send to the server, You can also obviously add more variables as you need just like Fetch!"
}));
//If the server sends a message you can receive the message!
console.info("The server says: " + requestPOST);

Here is an explanation of the Function:

In GET it is not necessary since you can use fetch("URL");

In post it is like this:

//how fetch works:
fetch(theurl, method, contentToSend);

Advanced Fetch:

specify the content type in parameter 4, and in the parameter 5 extra healders like Authorization, etc. in Json example: { Authorization: "hepi" }

fetch-api-nashorn's People

Contributors

trollhunters501 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.