Change format of js response for single object requests

This commit is contained in:
George Shammas 2022-01-05 10:46:52 -05:00
parent 7b2fcd7473
commit 5a94b7a588
1 changed files with 2 additions and 2 deletions

View File

@ -175,8 +175,8 @@ func mainHandler(c *gin.Context) {
c.JSON(200, fieldResult) c.JSON(200, fieldResult)
} else if wantsJS { } else if wantsJS {
c.Writer.Header().Set("Content-Type", "application/javascript") c.Writer.Header().Set("Content-Type", "application/javascript")
response, _ := json.Marshal(map[string]interface{}{fields[0]: fieldResult}) response, _ := json.Marshal(fieldResult)
c.String(200, "ifconfig_io = %v\n", string(response)) c.String(200, "%v = %v\n", fields[0], string(response))
} else { } else {
c.String(200, fmt.Sprintln(fieldResult)) c.String(200, fmt.Sprintln(fieldResult))
} }