LogoLogo
  • Introduction
  • sdks
    • Feature Comparison
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Quick Start
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Server Side
    • Entities
    • Chunks
    • Dimensions
    • Events
    • Logging
    • Lua Environment
    • Git Primer
    • Physics
  • HTTP API
    • Authentication
    • Player API
  • Api Reference
    • Entity API
      • Create
      • Message
    • Client API
      • Message
    • Dimension API
      • Create
      • Delete
      • List
    • Events API
      • on_player_join
      • on_player_leave
    • Table API
      • Append
      • Remove
      • Join
    • Util API
      • Time
      • TimeMillis
    • HTTP Request API
      • Get
      • Post
      • Put
      • Delete
    • Physics API
      • NewBody
      • NewBoxShape
      • NewSphereShape
Powered by GitBook
On this page
  1. Api Reference
  2. HTTP Request API

Delete

api.http.Delete(url, headers)

Sends an HTTP request to an endpoint. It uses the standard HTTP method DELETE, to indicate that the request wishes to delete information.

Parameters:

Name
Type
Description

url

string

The address of the endpoint to send the request to.

headers

table

Provides additional information to the endpoint, on how it should respond to the request.

Returns:

Type
Description

int

The HTTP code relaying the success of the request or otherwise.

string

The body of the HTTP response to the request.

Example:

Send a DELETE request to an endpoint, removing some data.

-- init.lua
function init()
    if not chunk.Generated then
        local code, body = api.http.DELETE("https://eg.mydatabase.com/chunks", 
                            {
                                ["Content-Type"]="text/plain",
                                ["Authorisation"]="Basic YWxhZGRpbjp"})
        
        if code == 200 then
          print("Response returned successfully: "..body)
          print("Chunk data has been deleted.")
        else
          print("Response returned HTTP code: "..code)
        end
    end
end

-- Send a DELETE HTTP request to the url https://eg.mydatabase.com/chunks.
-- The endpoint url removes some existing data.
-- The endpoint responds with a message about the data removed.
-- The string body of the response is printed.

-- Prints (dependent on endpoint response):
-- Response returned successfully: Chunks were lame. Chunks are
-- Chunk data has been deleted.

-- Or Prints (exact code number varies):
-- Response returned HTTP code: 404

PreviousPutNextPhysics API

Last updated 2 months ago